mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-10 07:25:35 +00:00
Compare commits
1 Commits
migration-
...
remove_ina
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
05f067a430 |
467
.adonisjs/api.ts
467
.adonisjs/api.ts
@@ -1,467 +0,0 @@
|
|||||||
import type { MakeTuyauRequest, MakeTuyauResponse } from '@tuyau/utils/types';
|
|
||||||
import type { InferInput } from '@vinejs/vine/types';
|
|
||||||
|
|
||||||
type UserThemePost = {
|
|
||||||
request: MakeTuyauRequest<
|
|
||||||
InferInput<
|
|
||||||
(typeof import('../app/validators/user.ts'))['updateUserThemeValidator']
|
|
||||||
>
|
|
||||||
>;
|
|
||||||
response: MakeTuyauResponse<
|
|
||||||
import('../app/controllers/apps_controller.ts').default['updateUserTheme']
|
|
||||||
>;
|
|
||||||
};
|
|
||||||
type FaviconGetHead = {
|
|
||||||
request: unknown;
|
|
||||||
response: MakeTuyauResponse<
|
|
||||||
import('../app/controllers/favicons_controller.ts').default['index']
|
|
||||||
>;
|
|
||||||
};
|
|
||||||
type SharedIdGetHead = {
|
|
||||||
request: MakeTuyauRequest<
|
|
||||||
InferInput<
|
|
||||||
(typeof import('../app/validators/shared_collection.ts'))['getSharedCollectionValidator']
|
|
||||||
>
|
|
||||||
>;
|
|
||||||
response: MakeTuyauResponse<
|
|
||||||
import('../app/controllers/shared_collections_controller.ts').default['index']
|
|
||||||
>;
|
|
||||||
};
|
|
||||||
type AdminGetHead = {
|
|
||||||
request: unknown;
|
|
||||||
response: MakeTuyauResponse<
|
|
||||||
import('../app/controllers/admin_controller.ts').default['index']
|
|
||||||
>;
|
|
||||||
};
|
|
||||||
type AuthLoginGetHead = {
|
|
||||||
request: unknown;
|
|
||||||
response: MakeTuyauResponse<
|
|
||||||
import('../app/controllers/users_controller.ts').default['login']
|
|
||||||
>;
|
|
||||||
};
|
|
||||||
type AuthCallbackGetHead = {
|
|
||||||
request: unknown;
|
|
||||||
response: MakeTuyauResponse<
|
|
||||||
import('../app/controllers/users_controller.ts').default['callbackAuth']
|
|
||||||
>;
|
|
||||||
};
|
|
||||||
type AuthLogoutGetHead = {
|
|
||||||
request: unknown;
|
|
||||||
response: MakeTuyauResponse<
|
|
||||||
import('../app/controllers/users_controller.ts').default['logout']
|
|
||||||
>;
|
|
||||||
};
|
|
||||||
type DashboardGetHead = {
|
|
||||||
request: unknown;
|
|
||||||
response: MakeTuyauResponse<
|
|
||||||
import('../app/controllers/collections_controller.ts').default['index']
|
|
||||||
>;
|
|
||||||
};
|
|
||||||
type CollectionsCreateGetHead = {
|
|
||||||
request: unknown;
|
|
||||||
response: MakeTuyauResponse<
|
|
||||||
import('../app/controllers/collections_controller.ts').default['showCreatePage']
|
|
||||||
>;
|
|
||||||
};
|
|
||||||
type CollectionsPost = {
|
|
||||||
request: MakeTuyauRequest<
|
|
||||||
InferInput<
|
|
||||||
(typeof import('../app/validators/collection.ts'))['createCollectionValidator']
|
|
||||||
>
|
|
||||||
>;
|
|
||||||
response: MakeTuyauResponse<
|
|
||||||
import('../app/controllers/collections_controller.ts').default['store']
|
|
||||||
>;
|
|
||||||
};
|
|
||||||
type CollectionsEditGetHead = {
|
|
||||||
request: unknown;
|
|
||||||
response: MakeTuyauResponse<
|
|
||||||
import('../app/controllers/collections_controller.ts').default['showEditPage']
|
|
||||||
>;
|
|
||||||
};
|
|
||||||
type CollectionsIdPut = {
|
|
||||||
request: MakeTuyauRequest<
|
|
||||||
InferInput<
|
|
||||||
(typeof import('../app/validators/collection.ts'))['updateCollectionValidator']
|
|
||||||
>
|
|
||||||
>;
|
|
||||||
response: MakeTuyauResponse<
|
|
||||||
import('../app/controllers/collections_controller.ts').default['update']
|
|
||||||
>;
|
|
||||||
};
|
|
||||||
type CollectionsDeleteGetHead = {
|
|
||||||
request: unknown;
|
|
||||||
response: MakeTuyauResponse<
|
|
||||||
import('../app/controllers/collections_controller.ts').default['showDeletePage']
|
|
||||||
>;
|
|
||||||
};
|
|
||||||
type CollectionsIdDelete = {
|
|
||||||
request: MakeTuyauRequest<
|
|
||||||
InferInput<
|
|
||||||
(typeof import('../app/validators/collection.ts'))['deleteCollectionValidator']
|
|
||||||
>
|
|
||||||
>;
|
|
||||||
response: MakeTuyauResponse<
|
|
||||||
import('../app/controllers/collections_controller.ts').default['delete']
|
|
||||||
>;
|
|
||||||
};
|
|
||||||
type LinksCreateGetHead = {
|
|
||||||
request: unknown;
|
|
||||||
response: MakeTuyauResponse<
|
|
||||||
import('../app/controllers/links_controller.ts').default['showCreatePage']
|
|
||||||
>;
|
|
||||||
};
|
|
||||||
type LinksPost = {
|
|
||||||
request: MakeTuyauRequest<
|
|
||||||
InferInput<
|
|
||||||
(typeof import('../app/validators/link.ts'))['createLinkValidator']
|
|
||||||
>
|
|
||||||
>;
|
|
||||||
response: MakeTuyauResponse<
|
|
||||||
import('../app/controllers/links_controller.ts').default['store']
|
|
||||||
>;
|
|
||||||
};
|
|
||||||
type LinksEditGetHead = {
|
|
||||||
request: unknown;
|
|
||||||
response: MakeTuyauResponse<
|
|
||||||
import('../app/controllers/links_controller.ts').default['showEditPage']
|
|
||||||
>;
|
|
||||||
};
|
|
||||||
type LinksIdPut = {
|
|
||||||
request: MakeTuyauRequest<
|
|
||||||
InferInput<
|
|
||||||
(typeof import('../app/validators/link.ts'))['updateLinkValidator']
|
|
||||||
>
|
|
||||||
>;
|
|
||||||
response: MakeTuyauResponse<
|
|
||||||
import('../app/controllers/links_controller.ts').default['update']
|
|
||||||
>;
|
|
||||||
};
|
|
||||||
type LinksIdFavoritePut = {
|
|
||||||
request: MakeTuyauRequest<
|
|
||||||
InferInput<
|
|
||||||
(typeof import('../app/validators/link.ts'))['updateLinkFavoriteStatusValidator']
|
|
||||||
>
|
|
||||||
>;
|
|
||||||
response: MakeTuyauResponse<
|
|
||||||
import('../app/controllers/links_controller.ts').default['toggleFavorite']
|
|
||||||
>;
|
|
||||||
};
|
|
||||||
type LinksDeleteGetHead = {
|
|
||||||
request: unknown;
|
|
||||||
response: MakeTuyauResponse<
|
|
||||||
import('../app/controllers/links_controller.ts').default['showDeletePage']
|
|
||||||
>;
|
|
||||||
};
|
|
||||||
type LinksIdDelete = {
|
|
||||||
request: MakeTuyauRequest<
|
|
||||||
InferInput<
|
|
||||||
(typeof import('../app/validators/link.ts'))['deleteLinkValidator']
|
|
||||||
>
|
|
||||||
>;
|
|
||||||
response: MakeTuyauResponse<
|
|
||||||
import('../app/controllers/links_controller.ts').default['delete']
|
|
||||||
>;
|
|
||||||
};
|
|
||||||
type SearchGetHead = {
|
|
||||||
request: MakeTuyauRequest<
|
|
||||||
InferInput<
|
|
||||||
(typeof import('../app/validators/search_term.ts'))['searchTermValidator']
|
|
||||||
>
|
|
||||||
>;
|
|
||||||
response: MakeTuyauResponse<
|
|
||||||
import('../app/controllers/searches_controller.ts').default['search']
|
|
||||||
>;
|
|
||||||
};
|
|
||||||
export interface ApiDefinition {
|
|
||||||
user: {
|
|
||||||
theme: {
|
|
||||||
$url: {};
|
|
||||||
$post: UserThemePost;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
favicon: {
|
|
||||||
$url: {};
|
|
||||||
$get: FaviconGetHead;
|
|
||||||
$head: FaviconGetHead;
|
|
||||||
};
|
|
||||||
shared: {
|
|
||||||
':id': {
|
|
||||||
$url: {};
|
|
||||||
$get: SharedIdGetHead;
|
|
||||||
$head: SharedIdGetHead;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
admin: {
|
|
||||||
$url: {};
|
|
||||||
$get: AdminGetHead;
|
|
||||||
$head: AdminGetHead;
|
|
||||||
};
|
|
||||||
auth: {
|
|
||||||
login: {
|
|
||||||
$url: {};
|
|
||||||
$get: AuthLoginGetHead;
|
|
||||||
$head: AuthLoginGetHead;
|
|
||||||
};
|
|
||||||
callback: {
|
|
||||||
$url: {};
|
|
||||||
$get: AuthCallbackGetHead;
|
|
||||||
$head: AuthCallbackGetHead;
|
|
||||||
};
|
|
||||||
logout: {
|
|
||||||
$url: {};
|
|
||||||
$get: AuthLogoutGetHead;
|
|
||||||
$head: AuthLogoutGetHead;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
dashboard: {
|
|
||||||
$url: {};
|
|
||||||
$get: DashboardGetHead;
|
|
||||||
$head: DashboardGetHead;
|
|
||||||
};
|
|
||||||
collections: {
|
|
||||||
create: {
|
|
||||||
$url: {};
|
|
||||||
$get: CollectionsCreateGetHead;
|
|
||||||
$head: CollectionsCreateGetHead;
|
|
||||||
};
|
|
||||||
$url: {};
|
|
||||||
$post: CollectionsPost;
|
|
||||||
edit: {
|
|
||||||
$url: {};
|
|
||||||
$get: CollectionsEditGetHead;
|
|
||||||
$head: CollectionsEditGetHead;
|
|
||||||
};
|
|
||||||
':id': {
|
|
||||||
$url: {};
|
|
||||||
$put: CollectionsIdPut;
|
|
||||||
$delete: CollectionsIdDelete;
|
|
||||||
};
|
|
||||||
delete: {
|
|
||||||
$url: {};
|
|
||||||
$get: CollectionsDeleteGetHead;
|
|
||||||
$head: CollectionsDeleteGetHead;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
links: {
|
|
||||||
create: {
|
|
||||||
$url: {};
|
|
||||||
$get: LinksCreateGetHead;
|
|
||||||
$head: LinksCreateGetHead;
|
|
||||||
};
|
|
||||||
$url: {};
|
|
||||||
$post: LinksPost;
|
|
||||||
edit: {
|
|
||||||
$url: {};
|
|
||||||
$get: LinksEditGetHead;
|
|
||||||
$head: LinksEditGetHead;
|
|
||||||
};
|
|
||||||
':id': {
|
|
||||||
$url: {};
|
|
||||||
$put: LinksIdPut;
|
|
||||||
favorite: {
|
|
||||||
$url: {};
|
|
||||||
$put: LinksIdFavoritePut;
|
|
||||||
};
|
|
||||||
$delete: LinksIdDelete;
|
|
||||||
};
|
|
||||||
delete: {
|
|
||||||
$url: {};
|
|
||||||
$get: LinksDeleteGetHead;
|
|
||||||
$head: LinksDeleteGetHead;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
search: {
|
|
||||||
$url: {};
|
|
||||||
$get: SearchGetHead;
|
|
||||||
$head: SearchGetHead;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
const routes = [
|
|
||||||
{
|
|
||||||
params: [],
|
|
||||||
name: 'home',
|
|
||||||
path: '/',
|
|
||||||
method: ['GET', 'HEAD'],
|
|
||||||
types: {} as unknown,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
params: [],
|
|
||||||
name: 'terms',
|
|
||||||
path: '/terms',
|
|
||||||
method: ['GET', 'HEAD'],
|
|
||||||
types: {} as unknown,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
params: [],
|
|
||||||
name: 'privacy',
|
|
||||||
path: '/privacy',
|
|
||||||
method: ['GET', 'HEAD'],
|
|
||||||
types: {} as unknown,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
params: [],
|
|
||||||
name: 'user.theme',
|
|
||||||
path: '/user/theme',
|
|
||||||
method: ['POST'],
|
|
||||||
types: {} as UserThemePost,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
params: [],
|
|
||||||
name: 'favicon',
|
|
||||||
path: '/favicon',
|
|
||||||
method: ['GET', 'HEAD'],
|
|
||||||
types: {} as FaviconGetHead,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
params: ['id'],
|
|
||||||
name: 'shared',
|
|
||||||
path: '/shared/:id',
|
|
||||||
method: ['GET', 'HEAD'],
|
|
||||||
types: {} as SharedIdGetHead,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
params: [],
|
|
||||||
name: 'admin.dashboard',
|
|
||||||
path: '/admin',
|
|
||||||
method: ['GET', 'HEAD'],
|
|
||||||
types: {} as AdminGetHead,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
params: [],
|
|
||||||
name: 'auth.login',
|
|
||||||
path: '/auth/login',
|
|
||||||
method: ['GET', 'HEAD'],
|
|
||||||
types: {} as AuthLoginGetHead,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
params: [],
|
|
||||||
name: 'auth.google',
|
|
||||||
path: '/auth/google',
|
|
||||||
method: ['GET', 'HEAD'],
|
|
||||||
types: {} as unknown,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
params: [],
|
|
||||||
name: 'auth.callback',
|
|
||||||
path: '/auth/callback',
|
|
||||||
method: ['GET', 'HEAD'],
|
|
||||||
types: {} as AuthCallbackGetHead,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
params: [],
|
|
||||||
name: 'auth.logout',
|
|
||||||
path: '/auth/logout',
|
|
||||||
method: ['GET', 'HEAD'],
|
|
||||||
types: {} as AuthLogoutGetHead,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
params: [],
|
|
||||||
name: 'dashboard',
|
|
||||||
path: '/dashboard',
|
|
||||||
method: ['GET', 'HEAD'],
|
|
||||||
types: {} as DashboardGetHead,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
params: [],
|
|
||||||
name: 'collection.create-form',
|
|
||||||
path: '/collections/create',
|
|
||||||
method: ['GET', 'HEAD'],
|
|
||||||
types: {} as CollectionsCreateGetHead,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
params: [],
|
|
||||||
name: 'collection.create',
|
|
||||||
path: '/collections',
|
|
||||||
method: ['POST'],
|
|
||||||
types: {} as CollectionsPost,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
params: [],
|
|
||||||
name: 'collection.edit-form',
|
|
||||||
path: '/collections/edit',
|
|
||||||
method: ['GET', 'HEAD'],
|
|
||||||
types: {} as CollectionsEditGetHead,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
params: ['id'],
|
|
||||||
name: 'collection.edit',
|
|
||||||
path: '/collections/:id',
|
|
||||||
method: ['PUT'],
|
|
||||||
types: {} as CollectionsIdPut,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
params: [],
|
|
||||||
name: 'collection.delete-form',
|
|
||||||
path: '/collections/delete',
|
|
||||||
method: ['GET', 'HEAD'],
|
|
||||||
types: {} as CollectionsDeleteGetHead,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
params: ['id'],
|
|
||||||
name: 'collection.delete',
|
|
||||||
path: '/collections/:id',
|
|
||||||
method: ['DELETE'],
|
|
||||||
types: {} as CollectionsIdDelete,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
params: [],
|
|
||||||
name: 'link.create-form',
|
|
||||||
path: '/links/create',
|
|
||||||
method: ['GET', 'HEAD'],
|
|
||||||
types: {} as LinksCreateGetHead,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
params: [],
|
|
||||||
name: 'link.create',
|
|
||||||
path: '/links',
|
|
||||||
method: ['POST'],
|
|
||||||
types: {} as LinksPost,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
params: [],
|
|
||||||
name: 'link.edit-form',
|
|
||||||
path: '/links/edit',
|
|
||||||
method: ['GET', 'HEAD'],
|
|
||||||
types: {} as LinksEditGetHead,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
params: ['id'],
|
|
||||||
name: 'link.edit',
|
|
||||||
path: '/links/:id',
|
|
||||||
method: ['PUT'],
|
|
||||||
types: {} as LinksIdPut,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
params: ['id'],
|
|
||||||
name: 'link.toggle-favorite',
|
|
||||||
path: '/links/:id/favorite',
|
|
||||||
method: ['PUT'],
|
|
||||||
types: {} as LinksIdFavoritePut,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
params: [],
|
|
||||||
name: 'link.delete-form',
|
|
||||||
path: '/links/delete',
|
|
||||||
method: ['GET', 'HEAD'],
|
|
||||||
types: {} as LinksDeleteGetHead,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
params: ['id'],
|
|
||||||
name: 'link.delete',
|
|
||||||
path: '/links/:id',
|
|
||||||
method: ['DELETE'],
|
|
||||||
types: {} as LinksIdDelete,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
params: [],
|
|
||||||
name: 'search',
|
|
||||||
path: '/search',
|
|
||||||
method: ['GET', 'HEAD'],
|
|
||||||
types: {} as SearchGetHead,
|
|
||||||
},
|
|
||||||
] as const;
|
|
||||||
export const api = {
|
|
||||||
routes,
|
|
||||||
definition: {} as ApiDefinition,
|
|
||||||
};
|
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
root = true
|
root = true
|
||||||
|
|
||||||
[*]
|
[*]
|
||||||
indent_style = tab
|
indent_style = space
|
||||||
indent_size = 2
|
indent_size = 2
|
||||||
end_of_line = lf
|
end_of_line = lf
|
||||||
charset = utf-8
|
charset = utf-8
|
||||||
@@ -17,5 +17,8 @@ insert_final_newline = unset
|
|||||||
indent_style = unset
|
indent_style = unset
|
||||||
insert_final_newline = unset
|
insert_final_newline = unset
|
||||||
|
|
||||||
|
[MakeFile]
|
||||||
|
indent_style = space
|
||||||
|
|
||||||
[*.md]
|
[*.md]
|
||||||
trim_trailing_whitespace = false
|
trim_trailing_whitespace = false
|
||||||
|
|||||||
6
.vscode/settings.json
vendored
6
.vscode/settings.json
vendored
@@ -1,13 +1,13 @@
|
|||||||
{
|
{
|
||||||
"typescript.preferences.importModuleSpecifier": "non-relative",
|
"typescript.preferences.importModuleSpecifier": "non-relative",
|
||||||
/* Prefer tabs over spaces for accessibility */
|
/* Prefer tabs over spaces for accessibility */
|
||||||
"editor.insertSpaces": false,
|
"editor.insertSpaces": true,
|
||||||
"editor.detectIndentation": false,
|
"editor.detectIndentation": false,
|
||||||
/* Explorer */
|
/* Explorer */
|
||||||
"explorer.fileNesting.enabled": true,
|
"explorer.fileNesting.enabled": true,
|
||||||
"explorer.fileNesting.patterns": {
|
"explorer.fileNesting.patterns": {
|
||||||
"*.js": "${capture}.js.map, ${capture}.min.js, ${capture}.d.ts",
|
"*.js": "${capture}.js.map, ${capture}.min.js, ${capture}.d.ts",
|
||||||
"package.json": "pnpm-lock.yaml, tsconfig.json, eslint.config.js, .babelrc, vite.config.ts, .editorconfig",
|
"package.json": "package-lock.json, yarn.lock, pnpm-lock.yaml, rollup.config.mjs, tsconfig.json, eslint.config.js",
|
||||||
"Makefile": "*compose.yml, Dockerfile, servers_pgadmin.json, .dockerignore"
|
"Makefile": "*compose.yml, Dockerfile, .dockerignore, *startup.sh"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
46
Dockerfile
46
Dockerfile
@@ -1,42 +1,62 @@
|
|||||||
# Source : https://github.com/adonisjs-community/adonis-packages/blob/main/Dockerfile
|
# Source : https://github.com/adonisjs-community/adonis-packages/blob/main/Dockerfile
|
||||||
|
|
||||||
FROM node:20-alpine3.18 as base
|
FROM node:20-alpine3.18 AS base
|
||||||
|
|
||||||
RUN apk --no-cache add curl
|
RUN apk --no-cache add curl
|
||||||
RUN corepack enable
|
RUN corepack enable
|
||||||
|
|
||||||
# All deps stage
|
# All deps stage
|
||||||
FROM base as deps
|
FROM base AS deps
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY package.json pnpm-lock.yaml /app/
|
ADD package.json pnpm-lock.yaml ./
|
||||||
COPY .adonisjs /app/.adonisjs
|
|
||||||
RUN pnpm install --ignore-scripts
|
RUN pnpm install --ignore-scripts
|
||||||
|
|
||||||
# Production only deps stage
|
# Production only deps stage
|
||||||
FROM base as production-deps
|
FROM base AS production-deps
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY package.json pnpm-lock.yaml /app/
|
ADD package.json pnpm-lock.yaml ./
|
||||||
COPY .adonisjs /app/.adonisjs
|
RUN pnpm install --ignore-scripts
|
||||||
RUN pnpm install --ignore-scripts --prod
|
|
||||||
|
|
||||||
# Build stage
|
# Build stage
|
||||||
FROM base as build
|
FROM base AS build
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=deps /app/node_modules /app/node_modules
|
COPY --from=deps /app/node_modules /app/node_modules
|
||||||
COPY . /app
|
ADD . .
|
||||||
|
|
||||||
|
ENV PORT=3333
|
||||||
|
ENV HOST=localhost
|
||||||
|
ENV LOG_LEVEL=info
|
||||||
|
ENV APP_KEY=sLoJth45JD1vcS8n92Y2JUd8w3OL4HQb
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
ENV SESSION_DRIVER=cookie
|
||||||
|
ENV DB_HOST=127.0.0.1
|
||||||
|
ENV DB_PORT=5432
|
||||||
|
ENV DB_USER=db_user
|
||||||
|
ENV DB_PASSWORD=db_password
|
||||||
|
ENV DB_DATABASE=db_db
|
||||||
|
ENV GOOGLE_CLIENT_ID=client_id
|
||||||
|
ENV GOOGLE_CLIENT_SECRET=client_secret
|
||||||
|
ENV GOOGLE_CLIENT_CALLBACK_URL=http://localhost:3333/auth/callback
|
||||||
|
|
||||||
|
RUN node ace izzy:routes
|
||||||
RUN node ace build
|
RUN node ace build
|
||||||
|
|
||||||
# Production stage
|
# Production stage
|
||||||
FROM base
|
FROM base
|
||||||
|
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
|
ENV LOG_LEVEL=debug
|
||||||
|
ENV CACHE_VIEWS=false
|
||||||
|
ENV SESSION_DRIVER=cookie
|
||||||
|
ENV PORT=$PORT
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=production-deps /app/node_modules /app/node_modules
|
COPY --from=production-deps /app/node_modules /app/node_modules
|
||||||
COPY --from=production-deps /app/.adonisjs /app/.adonisjs
|
|
||||||
COPY --from=build /app/build /app
|
COPY --from=build /app/build /app
|
||||||
|
COPY --from=build /app/startup.sh /app/startup.sh
|
||||||
|
|
||||||
# Expose port
|
# Expose port
|
||||||
EXPOSE $PORT
|
EXPOSE $PORT
|
||||||
|
|
||||||
# Start app
|
# Start app
|
||||||
CMD node bin/console.js migration:run --force && node bin/server.js
|
CMD node bin/console.js migration:run --force && sh startup.sh
|
||||||
|
|
||||||
|
|||||||
10
Makefile
10
Makefile
@@ -1,13 +1,11 @@
|
|||||||
dev:
|
dev:
|
||||||
@docker compose down
|
@docker compose down
|
||||||
@docker compose -f dev.compose.yml pull
|
@docker compose -f dev.docker-compose.yml up -d --wait
|
||||||
@docker compose -f dev.compose.yml up -d --wait
|
|
||||||
@node ace migration:fresh
|
@node ace migration:fresh
|
||||||
@pnpm run dev
|
@./dev.startup.sh
|
||||||
|
|
||||||
prod:
|
prod:
|
||||||
@docker compose -f dev.compose.yml down
|
@docker compose -f dev.docker-compose.yml down
|
||||||
@docker compose pull
|
|
||||||
@docker compose up -d --build --wait
|
@docker compose up -d --build --wait
|
||||||
|
|
||||||
seed:
|
seed:
|
||||||
@@ -15,7 +13,7 @@ seed:
|
|||||||
|
|
||||||
down:
|
down:
|
||||||
@-docker compose down
|
@-docker compose down
|
||||||
@-docker compose -f dev.compose.yml down
|
@-docker compose -f dev.docker-compose.yml down
|
||||||
|
|
||||||
release:
|
release:
|
||||||
@pnpm run release
|
@pnpm run release
|
||||||
|
|||||||
19
adonisrc.ts
19
adonisrc.ts
@@ -13,7 +13,8 @@ export default defineConfig({
|
|||||||
commands: [
|
commands: [
|
||||||
() => import('@adonisjs/core/commands'),
|
() => import('@adonisjs/core/commands'),
|
||||||
() => import('@adonisjs/lucid/commands'),
|
() => import('@adonisjs/lucid/commands'),
|
||||||
() => import('@tuyau/core/commands'),
|
() => import('@izzyjs/route/commands'),
|
||||||
|
() => import('adonisjs-scheduler/commands'),
|
||||||
],
|
],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -43,8 +44,12 @@ export default defineConfig({
|
|||||||
() => import('@adonisjs/auth/auth_provider'),
|
() => import('@adonisjs/auth/auth_provider'),
|
||||||
() => import('@adonisjs/inertia/inertia_provider'),
|
() => import('@adonisjs/inertia/inertia_provider'),
|
||||||
() => import('@adonisjs/ally/ally_provider'),
|
() => import('@adonisjs/ally/ally_provider'),
|
||||||
|
() => import('@izzyjs/route/izzy_provider'),
|
||||||
() => import('#providers/route_provider'),
|
() => import('#providers/route_provider'),
|
||||||
() => import('@tuyau/core/tuyau_provider'),
|
{
|
||||||
|
file: () => import('adonisjs-scheduler/scheduler_provider'),
|
||||||
|
environment: ['console'],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -55,7 +60,14 @@ export default defineConfig({
|
|||||||
| List of modules to import before starting the application.
|
| List of modules to import before starting the application.
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
preloads: [() => import('#start/routes'), () => import('#start/kernel')],
|
preloads: [
|
||||||
|
() => import('#start/routes'),
|
||||||
|
() => import('#start/kernel'),
|
||||||
|
{
|
||||||
|
file: () => import('#start/scheduler'),
|
||||||
|
environment: ['console'],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
@@ -105,5 +117,6 @@ export default defineConfig({
|
|||||||
assetsBundler: false,
|
assetsBundler: false,
|
||||||
unstable_assembler: {
|
unstable_assembler: {
|
||||||
onBuildStarting: [() => import('@adonisjs/vite/build_hook')],
|
onBuildStarting: [() => import('@adonisjs/vite/build_hook')],
|
||||||
|
onDevServerStarted: [() => import('@izzyjs/route/dev_hook')],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -14,12 +14,12 @@ class UserWithRelationCountDto {
|
|||||||
fullname: this.user.name,
|
fullname: this.user.name,
|
||||||
avatarUrl: this.user.avatarUrl,
|
avatarUrl: this.user.avatarUrl,
|
||||||
isAdmin: this.user.isAdmin,
|
isAdmin: this.user.isAdmin,
|
||||||
createdAt: this.user.createdAt.toString(),
|
createdAt: this.user.createdAt,
|
||||||
updatedAt: this.user.updatedAt.toString(),
|
updatedAt: this.user.updatedAt,
|
||||||
lastSeenAt:
|
count: {
|
||||||
this.user.lastSeenAt?.toString() ?? this.user.updatedAt.toString(),
|
link: Number(this.user.$extras.totalLinks),
|
||||||
linksCount: Number(this.user.$extras.totalLinks),
|
collection: Number(this.user.$extras.totalCollections),
|
||||||
collectionsCount: Number(this.user.$extras.totalCollections),
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,16 @@
|
|||||||
import { searchTermValidator } from '#validators/search_term';
|
|
||||||
import type { HttpContext } from '@adonisjs/core/http';
|
import type { HttpContext } from '@adonisjs/core/http';
|
||||||
import db from '@adonisjs/lucid/services/db';
|
import db from '@adonisjs/lucid/services/db';
|
||||||
|
|
||||||
export default class SearchesController {
|
export default class SearchesController {
|
||||||
async search({ request, auth }: HttpContext) {
|
async search({ request, auth }: HttpContext) {
|
||||||
const { searchTerm } = await request.validateUsing(searchTermValidator);
|
const term = request.qs()?.term;
|
||||||
|
if (!term) {
|
||||||
|
console.warn('qs term null');
|
||||||
|
return { error: 'missing "term" query param' };
|
||||||
|
}
|
||||||
|
|
||||||
const { rows } = await db.rawQuery('SELECT * FROM search_text(?, ?)', [
|
const { rows } = await db.rawQuery('SELECT * FROM search_text(?, ?)', [
|
||||||
searchTerm,
|
term,
|
||||||
auth.user!.id,
|
auth.user!.id,
|
||||||
]);
|
]);
|
||||||
return { results: rows };
|
return { results: rows };
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
import User from '#models/user';
|
import User from '#models/user';
|
||||||
import { RouteName } from '#types/tuyau';
|
|
||||||
import type { HttpContext } from '@adonisjs/core/http';
|
import type { HttpContext } from '@adonisjs/core/http';
|
||||||
import logger from '@adonisjs/core/services/logger';
|
import logger from '@adonisjs/core/services/logger';
|
||||||
import db from '@adonisjs/lucid/services/db';
|
import db from '@adonisjs/lucid/services/db';
|
||||||
|
import { RouteName } from '@izzyjs/route/types';
|
||||||
|
|
||||||
|
const INACTIVE_USER_THRESHOLD = 7;
|
||||||
|
|
||||||
export default class UsersController {
|
export default class UsersController {
|
||||||
private redirectTo: RouteName = 'auth.login';
|
private redirectTo: RouteName = 'auth.login';
|
||||||
@@ -75,4 +77,18 @@ export default class UsersController {
|
|||||||
.withCount('collections', (q) => q.as('totalCollections'))
|
.withCount('collections', (q) => q.as('totalCollections'))
|
||||||
.withCount('links', (q) => q.as('totalLinks'));
|
.withCount('links', (q) => q.as('totalLinks'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getAllInactiveUsers() {
|
||||||
|
const users = await this.getAllUsersWithTotalRelations();
|
||||||
|
const inactiveUsers = users.filter((user) => {
|
||||||
|
const totalLinks = Number(user.$extras.totalLinks);
|
||||||
|
const totalCollections = Number(user.$extras.totalCollections);
|
||||||
|
|
||||||
|
const isOlderThan7Days =
|
||||||
|
Math.abs(user.updatedAt.diffNow('days').days) > INACTIVE_USER_THRESHOLD;
|
||||||
|
|
||||||
|
return (totalLinks === 0 || totalCollections === 0) && isOlderThan7Days;
|
||||||
|
});
|
||||||
|
return inactiveUsers ?? [];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
import { api } from '#adonisjs/api';
|
|
||||||
import { QueryParams } from '#types/query_params';
|
|
||||||
import { RouteName } from '#types/tuyau';
|
|
||||||
|
|
||||||
export const getRoute = (routeName: RouteName, options?: QueryParams) => {
|
|
||||||
const current = api.routes.find((route) => route.name === routeName);
|
|
||||||
if (!current) {
|
|
||||||
throw new Error(`Route ${routeName} not found`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options?.qs) {
|
|
||||||
const searchParams = new URLSearchParams(options?.qs);
|
|
||||||
return { ...current, path: `${current.path}?${searchParams.toString()}` };
|
|
||||||
}
|
|
||||||
|
|
||||||
return current;
|
|
||||||
};
|
|
||||||
|
|
||||||
export function getPath(routeName: RouteName, options?: QueryParams) {
|
|
||||||
const current = getRoute(routeName, options);
|
|
||||||
return current.path;
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { getPath } from '#lib/tuyau';
|
|
||||||
import type { Authenticators } from '@adonisjs/auth/types';
|
import type { Authenticators } from '@adonisjs/auth/types';
|
||||||
import type { HttpContext } from '@adonisjs/core/http';
|
import type { HttpContext } from '@adonisjs/core/http';
|
||||||
import type { NextFn } from '@adonisjs/core/types/http';
|
import type { NextFn } from '@adonisjs/core/types/http';
|
||||||
|
import { route } from '@izzyjs/route/client';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Auth middleware is used authenticate HTTP requests and deny
|
* Auth middleware is used authenticate HTTP requests and deny
|
||||||
@@ -11,7 +11,7 @@ export default class AuthMiddleware {
|
|||||||
/**
|
/**
|
||||||
* The URL to redirect to, when authentication fails
|
* The URL to redirect to, when authentication fails
|
||||||
*/
|
*/
|
||||||
redirectTo = getPath('auth.login');
|
redirectTo = route('auth.login').url;
|
||||||
|
|
||||||
async handle(
|
async handle(
|
||||||
ctx: HttpContext,
|
ctx: HttpContext,
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
import type { HttpContext } from '@adonisjs/core/http';
|
|
||||||
import type { NextFn } from '@adonisjs/core/types/http';
|
|
||||||
|
|
||||||
export default class SilentAuthMiddleware {
|
|
||||||
async handle(ctx: HttpContext, next: NextFn) {
|
|
||||||
await ctx.auth.check();
|
|
||||||
return next();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
import type { HttpContext } from '@adonisjs/core/http';
|
|
||||||
import type { NextFn } from '@adonisjs/core/types/http';
|
|
||||||
import { DateTime } from 'luxon';
|
|
||||||
|
|
||||||
export default class UpdateUserLastSeenMiddleware {
|
|
||||||
async handle(ctx: HttpContext, next: NextFn) {
|
|
||||||
const user = ctx.auth.user;
|
|
||||||
if (user) {
|
|
||||||
user.lastSeenAt = DateTime.local();
|
|
||||||
await user.save();
|
|
||||||
}
|
|
||||||
|
|
||||||
const output = await next();
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,7 +4,6 @@ import type { GoogleToken } from '@adonisjs/ally/types';
|
|||||||
import { column, computed, hasMany } from '@adonisjs/lucid/orm';
|
import { column, computed, hasMany } from '@adonisjs/lucid/orm';
|
||||||
import type { HasMany } from '@adonisjs/lucid/types/relations';
|
import type { HasMany } from '@adonisjs/lucid/types/relations';
|
||||||
import AppBaseModel from './app_base_model.js';
|
import AppBaseModel from './app_base_model.js';
|
||||||
import { DateTime } from 'luxon';
|
|
||||||
|
|
||||||
export default class User extends AppBaseModel {
|
export default class User extends AppBaseModel {
|
||||||
@column()
|
@column()
|
||||||
@@ -45,10 +44,4 @@ export default class User extends AppBaseModel {
|
|||||||
get fullname() {
|
get fullname() {
|
||||||
return this.nickName || this.name;
|
return this.nickName || this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@column.dateTime({
|
|
||||||
autoCreate: true,
|
|
||||||
autoUpdate: true,
|
|
||||||
})
|
|
||||||
declare lastSeenAt: DateTime;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
export type QueryParams = { qs?: Record<string, any> };
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
import { api } from '#adonisjs/api';
|
|
||||||
|
|
||||||
export type RouteName = (typeof api)['routes'][number]['name'];
|
|
||||||
export type RouteParams = (typeof api)['routes'][number]['params'];
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
import vine from '@vinejs/vine';
|
|
||||||
|
|
||||||
export const searchTermValidator = vine.compile(
|
|
||||||
vine.object({
|
|
||||||
searchTerm: vine.string().trim().minLength(1).maxLength(255),
|
|
||||||
})
|
|
||||||
);
|
|
||||||
18
commands/remove_inactive_users.ts
Normal file
18
commands/remove_inactive_users.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import UsersController from '#controllers/users_controller';
|
||||||
|
import { inject } from '@adonisjs/core';
|
||||||
|
import { BaseCommand } from '@adonisjs/core/ace';
|
||||||
|
import type { CommandOptions } from '@adonisjs/core/types/ace';
|
||||||
|
|
||||||
|
export default class RemoveInactiveUsers extends BaseCommand {
|
||||||
|
static commandName = 'remove:inactive-users';
|
||||||
|
static description = '';
|
||||||
|
|
||||||
|
static options: CommandOptions = {};
|
||||||
|
|
||||||
|
@inject()
|
||||||
|
async run(usersController: UsersController) {
|
||||||
|
const inactiveUsers = await usersController.getAllInactiveUsers();
|
||||||
|
await Promise.all(inactiveUsers.map((user) => user.delete()));
|
||||||
|
console.log(`Removed ${inactiveUsers.length} inactive users`);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
import { defineConfig } from '@tuyau/core'
|
|
||||||
|
|
||||||
const tuyauConfig = defineConfig({
|
|
||||||
codegen: {
|
|
||||||
/**
|
|
||||||
* Filters the definitions and named routes to be generated
|
|
||||||
*/
|
|
||||||
// definitions: {
|
|
||||||
// only: [],
|
|
||||||
// }
|
|
||||||
// routes: {
|
|
||||||
// only: [],
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
export default tuyauConfig
|
|
||||||
@@ -5,14 +5,7 @@ export default class CreateUsersTable extends BaseSchema {
|
|||||||
static tableName = 'users';
|
static tableName = 'users';
|
||||||
|
|
||||||
async up() {
|
async up() {
|
||||||
const exists = await this.schema.hasTable(CreateUsersTable.tableName);
|
this.schema.createTableIfNotExists(CreateUsersTable.tableName, (table) => {
|
||||||
if (exists) {
|
|
||||||
return console.warn(
|
|
||||||
`Table ${CreateUsersTable.tableName} already exists.`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.schema.createTable(CreateUsersTable.tableName, (table) => {
|
|
||||||
table.string('email', 254).notNullable().unique();
|
table.string('email', 254).notNullable().unique();
|
||||||
table.string('name', 254).notNullable();
|
table.string('name', 254).notNullable();
|
||||||
table.string('nick_name', 254).nullable();
|
table.string('nick_name', 254).nullable();
|
||||||
|
|||||||
@@ -8,14 +8,9 @@ export default class CreateCollectionTable extends BaseSchema {
|
|||||||
|
|
||||||
async up() {
|
async up() {
|
||||||
this.schema.raw(`DROP TYPE IF EXISTS ${this.visibilityEnumName}`);
|
this.schema.raw(`DROP TYPE IF EXISTS ${this.visibilityEnumName}`);
|
||||||
const exists = await this.schema.hasTable(CreateCollectionTable.tableName);
|
this.schema.createTableIfNotExists(
|
||||||
if (exists) {
|
CreateCollectionTable.tableName,
|
||||||
return console.warn(
|
(table) => {
|
||||||
`Table ${CreateCollectionTable.tableName} already exists.`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.schema.createTable(CreateCollectionTable.tableName, (table) => {
|
|
||||||
table.string('name', 254).notNullable();
|
table.string('name', 254).notNullable();
|
||||||
table.string('description', 254).nullable();
|
table.string('description', 254).nullable();
|
||||||
table
|
table
|
||||||
@@ -38,7 +33,8 @@ export default class CreateCollectionTable extends BaseSchema {
|
|||||||
.onDelete('CASCADE');
|
.onDelete('CASCADE');
|
||||||
|
|
||||||
defaultTableFields(table);
|
defaultTableFields(table);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async down() {
|
async down() {
|
||||||
|
|||||||
@@ -5,13 +5,7 @@ export default class CreateLinksTable extends BaseSchema {
|
|||||||
static tableName = 'links';
|
static tableName = 'links';
|
||||||
|
|
||||||
async up() {
|
async up() {
|
||||||
const exists = await this.schema.hasTable(CreateLinksTable.tableName);
|
this.schema.createTableIfNotExists(CreateLinksTable.tableName, (table) => {
|
||||||
if (exists) {
|
|
||||||
return console.warn(`Table ${CreateLinksTable.tableName} already
|
|
||||||
exists.`);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.schema.createTable(CreateLinksTable.tableName, (table) => {
|
|
||||||
table.string('name', 254).notNullable();
|
table.string('name', 254).notNullable();
|
||||||
table.string('description', 254).nullable();
|
table.string('description', 254).nullable();
|
||||||
table.text('url').notNullable();
|
table.text('url').notNullable();
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
import { BaseSchema } from '@adonisjs/lucid/schema';
|
|
||||||
|
|
||||||
export default class extends BaseSchema {
|
|
||||||
protected tableName = 'users';
|
|
||||||
|
|
||||||
async up() {
|
|
||||||
this.schema.alterTable(this.tableName, (table) => {
|
|
||||||
table.timestamp('last_seen_at');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async down() {
|
|
||||||
this.schema.dropTable(this.tableName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
name: my-links-dev
|
|
||||||
services:
|
|
||||||
postgres:
|
|
||||||
container_name: postgres
|
|
||||||
image: postgres:16
|
|
||||||
restart: always
|
|
||||||
environment:
|
|
||||||
- POSTGRES_DB=${DB_DATABASE}
|
|
||||||
- POSTGRES_USER=${DB_USER}
|
|
||||||
- POSTGRES_PASSWORD=${DB_PASSWORD}
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD-SHELL", "pg_isready", "-U", "${DB_USER}"]
|
|
||||||
volumes:
|
|
||||||
- postgres-volume:/var/lib/postgresql/data
|
|
||||||
ports:
|
|
||||||
- "${DB_PORT}:5432"
|
|
||||||
|
|
||||||
pgadmin:
|
|
||||||
container_name: pgadmin
|
|
||||||
image: dpage/pgadmin4:8
|
|
||||||
restart: always
|
|
||||||
entrypoint: /bin/sh -c "chmod 0600 /pgpass; /entrypoint.sh;"
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD", "wget", "-O", "-", "http://localhost:80/misc/ping"]
|
|
||||||
interval: 2s
|
|
||||||
timeout: 10s
|
|
||||||
retries: 30
|
|
||||||
env_file: .env
|
|
||||||
environment:
|
|
||||||
- PGADMIN_DEFAULT_EMAIL=myemail@gmail.com
|
|
||||||
- PGADMIN_DEFAULT_PASSWORD=a12345678
|
|
||||||
- PGADMIN_CONFIG_SERVER_MODE=False
|
|
||||||
- PGADMIN_CONFIG_MASTER_PASSWORD_REQUIRED=False
|
|
||||||
depends_on:
|
|
||||||
- postgres
|
|
||||||
ports:
|
|
||||||
- "5050:80"
|
|
||||||
user: root
|
|
||||||
configs:
|
|
||||||
- source: servers.json
|
|
||||||
target: /pgadmin4/servers.json
|
|
||||||
- source: pgpass
|
|
||||||
target: /pgpass
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
postgres-volume:
|
|
||||||
|
|
||||||
configs:
|
|
||||||
pgpass:
|
|
||||||
content: postgres:${DB_PORT}:*:${DB_USER}:${DB_PASSWORD}
|
|
||||||
servers.json:
|
|
||||||
content: |
|
|
||||||
{"Servers": {"1": {
|
|
||||||
"Group": "Servers",
|
|
||||||
"Name": "project",
|
|
||||||
"Host": "postgres",
|
|
||||||
"Port": ${DB_PORT},
|
|
||||||
"MaintenanceDB": "${DB_DATABASE}",
|
|
||||||
"Username": "${DB_USER}",
|
|
||||||
"PassFile": "/pgpass",
|
|
||||||
"SSLMode": "prefer"
|
|
||||||
}}}
|
|
||||||
34
dev.docker-compose.yml
Normal file
34
dev.docker-compose.yml
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
name: dev-stack
|
||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
container_name: postgres
|
||||||
|
image: postgres:16
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
- POSTGRES_DB=${DB_DATABASE}
|
||||||
|
- POSTGRES_USER=${DB_USER}
|
||||||
|
- POSTGRES_PASSWORD=${DB_PASSWORD}
|
||||||
|
healthcheck:
|
||||||
|
test: ['CMD-SHELL', 'pg_isready']
|
||||||
|
volumes:
|
||||||
|
- postgres_volume:/var/lib/postgresql/data
|
||||||
|
ports:
|
||||||
|
- '${DB_PORT}:5432'
|
||||||
|
|
||||||
|
pgadmin:
|
||||||
|
container_name: pgadmin
|
||||||
|
image: dpage/pgadmin4:8.6
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
- PGADMIN_DEFAULT_EMAIL=myemail@gmail.com
|
||||||
|
- PGADMIN_DEFAULT_PASSWORD=a12345678
|
||||||
|
depends_on:
|
||||||
|
- postgres
|
||||||
|
volumes:
|
||||||
|
- ./docker-config/servers_pgadmin.json:/pgadmin4/servers.json
|
||||||
|
ports:
|
||||||
|
- '5050:80'
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
postgres_volume:
|
||||||
|
name: postgres_test_dev_stack
|
||||||
6
dev.startup.sh
Executable file
6
dev.startup.sh
Executable file
@@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
(trap 'kill 0' SIGINT; node ace scheduler:run & pnpm run dev)
|
||||||
|
|
||||||
|
wait -n
|
||||||
|
exit $?
|
||||||
@@ -9,7 +9,7 @@ services:
|
|||||||
- POSTGRES_USER=${DB_USER}
|
- POSTGRES_USER=${DB_USER}
|
||||||
- POSTGRES_PASSWORD=${DB_PASSWORD}
|
- POSTGRES_PASSWORD=${DB_PASSWORD}
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ['CMD-SHELL', 'pg_isready', '-U', '${DB_USER}']
|
test: ['CMD-SHELL', 'pg_isready']
|
||||||
volumes:
|
volumes:
|
||||||
- postgres-volume:/var/lib/postgresql/data
|
- postgres-volume:/var/lib/postgresql/data
|
||||||
ports:
|
ports:
|
||||||
@@ -17,30 +17,22 @@ services:
|
|||||||
|
|
||||||
pgadmin:
|
pgadmin:
|
||||||
container_name: pgadmin
|
container_name: pgadmin
|
||||||
image: dpage/pgadmin4:8
|
image: dpage/pgadmin4:8.6
|
||||||
restart: always
|
restart: always
|
||||||
entrypoint: /bin/sh -c "chmod 0600 /pgpass; /entrypoint.sh;"
|
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ['CMD', 'wget', '-O', '-', 'http://localhost:80/misc/ping']
|
test: ['CMD', 'wget', '-O', '-', 'http://localhost:80/misc/ping']
|
||||||
interval: 2s
|
interval: 2s
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
retries: 30
|
retries: 30
|
||||||
env_file: .env
|
|
||||||
environment:
|
environment:
|
||||||
- PGADMIN_DEFAULT_EMAIL=myemail@gmail.com
|
- PGADMIN_DEFAULT_EMAIL=myemail@gmail.com
|
||||||
- PGADMIN_DEFAULT_PASSWORD=a12345678
|
- PGADMIN_DEFAULT_PASSWORD=a12345678
|
||||||
- PGADMIN_CONFIG_SERVER_MODE=False
|
|
||||||
- PGADMIN_CONFIG_MASTER_PASSWORD_REQUIRED=False
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- postgres
|
- postgres
|
||||||
|
volumes:
|
||||||
|
- ./docker-config/servers_pgadmin.json:/pgadmin4/servers.json
|
||||||
ports:
|
ports:
|
||||||
- '5050:80'
|
- '5050:80'
|
||||||
user: root
|
|
||||||
configs:
|
|
||||||
- source: servers.json
|
|
||||||
target: /pgadmin4/servers.json
|
|
||||||
- source: pgpass
|
|
||||||
target: /pgpass
|
|
||||||
|
|
||||||
my-links:
|
my-links:
|
||||||
container_name: my-links
|
container_name: my-links
|
||||||
@@ -61,19 +53,4 @@ services:
|
|||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
postgres-volume:
|
postgres-volume:
|
||||||
|
name: postgres-prod-my-links
|
||||||
configs:
|
|
||||||
pgpass:
|
|
||||||
content: postgres:${DB_PORT}:*:${DB_USER}:${DB_PASSWORD}
|
|
||||||
servers.json:
|
|
||||||
content: |
|
|
||||||
{"Servers": {"1": {
|
|
||||||
"Group": "Servers",
|
|
||||||
"Name": "project",
|
|
||||||
"Host": "postgres",
|
|
||||||
"Port": ${DB_PORT},
|
|
||||||
"MaintenanceDB": "${DB_DATABASE}",
|
|
||||||
"Username": "${DB_USER}",
|
|
||||||
"PassFile": "/pgpass",
|
|
||||||
"SSLMode": "prefer"
|
|
||||||
}}}
|
|
||||||
13
docker-config/servers_pgadmin.json
Normal file
13
docker-config/servers_pgadmin.json
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"Servers": {
|
||||||
|
"1": {
|
||||||
|
"Name": "project",
|
||||||
|
"Group": "Servers",
|
||||||
|
"Port": 5432,
|
||||||
|
"Username": "postgres",
|
||||||
|
"Host": "postgres",
|
||||||
|
"SSLMode": "prefer",
|
||||||
|
"MaintenanceDB": "my-links"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,14 +1,16 @@
|
|||||||
import { router } from '@inertiajs/react';
|
import { router } from '@inertiajs/react';
|
||||||
|
import { route } from '@izzyjs/route/client';
|
||||||
import { ReactNode } from 'react';
|
import { ReactNode } from 'react';
|
||||||
import useSearchParam from '~/hooks/use_search_param';
|
import useSearchParam from '~/hooks/use_search_param';
|
||||||
import useShortcut from '~/hooks/use_shortcut';
|
import useShortcut from '~/hooks/use_shortcut';
|
||||||
import { routeWithCollectionId } from '~/lib/navigation';
|
import { appendCollectionId } from '~/lib/navigation';
|
||||||
|
|
||||||
export default function BackToDashboard({ children }: { children: ReactNode }) {
|
export default function BackToDashboard({ children }: { children: ReactNode }) {
|
||||||
const collectionId = Number(useSearchParam('collectionId'));
|
const collectionId = Number(useSearchParam('collectionId'));
|
||||||
useShortcut(
|
useShortcut(
|
||||||
'ESCAPE_KEY',
|
'ESCAPE_KEY',
|
||||||
() => router.visit(routeWithCollectionId('dashboard', collectionId)),
|
() =>
|
||||||
|
router.visit(appendCollectionId(route('dashboard').url, collectionId)),
|
||||||
{ disableGlobalCheck: true }
|
{ disableGlobalCheck: true }
|
||||||
);
|
);
|
||||||
return <>{children}</>;
|
return <>{children}</>;
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import {
|
|||||||
getPaginationRowModel,
|
getPaginationRowModel,
|
||||||
getSortedRowModel,
|
getSortedRowModel,
|
||||||
PaginationState,
|
PaginationState,
|
||||||
SortingState,
|
|
||||||
useReactTable,
|
useReactTable,
|
||||||
} from '@tanstack/react-table';
|
} from '@tanstack/react-table';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
@@ -51,19 +50,13 @@ const Resizer = styled.div<{ isResizing: boolean }>(
|
|||||||
type TableProps<T> = {
|
type TableProps<T> = {
|
||||||
columns: ColumnDef<T>[];
|
columns: ColumnDef<T>[];
|
||||||
data: T[];
|
data: T[];
|
||||||
defaultSorting?: SortingState;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function Table<T>({
|
export default function Table<T>({ columns, data }: TableProps<T>) {
|
||||||
columns,
|
|
||||||
data,
|
|
||||||
defaultSorting = [],
|
|
||||||
}: TableProps<T>) {
|
|
||||||
const [pagination, setPagination] = useState<PaginationState>({
|
const [pagination, setPagination] = useState<PaginationState>({
|
||||||
pageIndex: 0,
|
pageIndex: 0,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
});
|
});
|
||||||
const [sorting, setSorting] = useState<SortingState>(defaultSorting);
|
|
||||||
|
|
||||||
const table = useReactTable({
|
const table = useReactTable({
|
||||||
data,
|
data,
|
||||||
@@ -72,13 +65,11 @@ export default function Table<T>({
|
|||||||
columnResizeMode: 'onChange',
|
columnResizeMode: 'onChange',
|
||||||
state: {
|
state: {
|
||||||
pagination,
|
pagination,
|
||||||
sorting,
|
|
||||||
},
|
},
|
||||||
onPaginationChange: setPagination,
|
onPaginationChange: setPagination,
|
||||||
getCoreRowModel: getCoreRowModel(),
|
getCoreRowModel: getCoreRowModel(),
|
||||||
getPaginationRowModel: getPaginationRowModel(),
|
getPaginationRowModel: getPaginationRowModel(),
|
||||||
getSortedRowModel: getSortedRowModel(),
|
getSortedRowModel: getSortedRowModel(),
|
||||||
onSortingChange: setSorting,
|
|
||||||
debugTable: true,
|
debugTable: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { route } from '@izzyjs/route/client';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { BsThreeDotsVertical } from 'react-icons/bs';
|
import { BsThreeDotsVertical } from 'react-icons/bs';
|
||||||
import { GoPencil } from 'react-icons/go';
|
import { GoPencil } from 'react-icons/go';
|
||||||
@@ -5,7 +6,7 @@ import { IoIosAddCircleOutline } from 'react-icons/io';
|
|||||||
import { IoTrashOutline } from 'react-icons/io5';
|
import { IoTrashOutline } from 'react-icons/io5';
|
||||||
import Dropdown from '~/components/common/dropdown/dropdown';
|
import Dropdown from '~/components/common/dropdown/dropdown';
|
||||||
import { DropdownItemLink } from '~/components/common/dropdown/dropdown_item';
|
import { DropdownItemLink } from '~/components/common/dropdown/dropdown_item';
|
||||||
import { getPath, routeWithCollectionId } from '~/lib/navigation';
|
import { appendCollectionId } from '~/lib/navigation';
|
||||||
import { Collection } from '~/types/app';
|
import { Collection } from '~/types/app';
|
||||||
|
|
||||||
export default function CollectionControls({
|
export default function CollectionControls({
|
||||||
@@ -16,16 +17,22 @@ export default function CollectionControls({
|
|||||||
const { t } = useTranslation('common');
|
const { t } = useTranslation('common');
|
||||||
return (
|
return (
|
||||||
<Dropdown label={<BsThreeDotsVertical />} svgSize={18}>
|
<Dropdown label={<BsThreeDotsVertical />} svgSize={18}>
|
||||||
<DropdownItemLink href={getPath('link.create-form')}>
|
<DropdownItemLink href={route('link.create-form').url}>
|
||||||
<IoIosAddCircleOutline /> {t('link.create')}
|
<IoIosAddCircleOutline /> {t('link.create')}
|
||||||
</DropdownItemLink>
|
</DropdownItemLink>
|
||||||
<DropdownItemLink
|
<DropdownItemLink
|
||||||
href={routeWithCollectionId('collection.edit-form', collectionId)}
|
href={appendCollectionId(
|
||||||
|
route('collection.edit-form').url,
|
||||||
|
collectionId
|
||||||
|
)}
|
||||||
>
|
>
|
||||||
<GoPencil /> {t('collection.edit')}
|
<GoPencil /> {t('collection.edit')}
|
||||||
</DropdownItemLink>
|
</DropdownItemLink>
|
||||||
<DropdownItemLink
|
<DropdownItemLink
|
||||||
href={routeWithCollectionId('collection.delete-form', collectionId)}
|
href={appendCollectionId(
|
||||||
|
route('collection.delete-form').url,
|
||||||
|
collectionId
|
||||||
|
)}
|
||||||
danger
|
danger
|
||||||
>
|
>
|
||||||
<IoTrashOutline /> {t('collection.delete')}
|
<IoTrashOutline /> {t('collection.delete')}
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
import { Link } from '@inertiajs/react';
|
import { Link } from '@inertiajs/react';
|
||||||
|
import { route } from '@izzyjs/route/client';
|
||||||
import { useEffect, useRef } from 'react';
|
import { useEffect, useRef } from 'react';
|
||||||
import { AiFillFolderOpen, AiOutlineFolder } from 'react-icons/ai';
|
import { AiFillFolderOpen, AiOutlineFolder } from 'react-icons/ai';
|
||||||
import TextEllipsis from '~/components/common/text_ellipsis';
|
import TextEllipsis from '~/components/common/text_ellipsis';
|
||||||
import { Item } from '~/components/dashboard/side_nav/nav_item';
|
import { Item } from '~/components/dashboard/side_nav/nav_item';
|
||||||
import useActiveCollection from '~/hooks/use_active_collection';
|
import useActiveCollection from '~/hooks/use_active_collection';
|
||||||
import { routeWithCollectionId } from '~/lib/navigation';
|
import { appendCollectionId } from '~/lib/navigation';
|
||||||
import { CollectionWithLinks } from '~/types/app';
|
import { CollectionWithLinks } from '~/types/app';
|
||||||
|
|
||||||
const CollectionItemStyle = styled(Item, {
|
const CollectionItemStyle = styled(Item, {
|
||||||
@@ -42,7 +43,7 @@ export default function CollectionItem({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<CollectionItemLink
|
<CollectionItemLink
|
||||||
href={routeWithCollectionId('dashboard', collection.id)}
|
href={appendCollectionId(route('dashboard').url, collection.id)}
|
||||||
isActive={isActiveCollection}
|
isActive={isActiveCollection}
|
||||||
ref={itemRef}
|
ref={itemRef}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
import { router } from '@inertiajs/react';
|
import { router } from '@inertiajs/react';
|
||||||
|
import { route } from '@izzyjs/route/client';
|
||||||
import { ReactNode, useMemo, useState } from 'react';
|
import { ReactNode, useMemo, useState } from 'react';
|
||||||
import { ActiveCollectionContext } from '~/contexts/active_collection_context';
|
import { ActiveCollectionContext } from '~/contexts/active_collection_context';
|
||||||
import CollectionsContext from '~/contexts/collections_context';
|
import CollectionsContext from '~/contexts/collections_context';
|
||||||
import FavoritesContext from '~/contexts/favorites_context';
|
import FavoritesContext from '~/contexts/favorites_context';
|
||||||
import GlobalHotkeysContext from '~/contexts/global_hotkeys_context';
|
import GlobalHotkeysContext from '~/contexts/global_hotkeys_context';
|
||||||
import useShortcut from '~/hooks/use_shortcut';
|
import useShortcut from '~/hooks/use_shortcut';
|
||||||
import { routeWithCollectionId } from '~/lib/navigation';
|
import { appendCollectionId } from '~/lib/navigation';
|
||||||
import { CollectionWithLinks, LinkWithCollection } from '~/types/app';
|
import { CollectionWithLinks, LinkWithCollection } from '~/types/app';
|
||||||
|
|
||||||
export default function DashboardProviders(
|
export default function DashboardProviders(
|
||||||
@@ -27,7 +28,7 @@ export default function DashboardProviders(
|
|||||||
|
|
||||||
const handleChangeCollection = (collection: CollectionWithLinks) => {
|
const handleChangeCollection = (collection: CollectionWithLinks) => {
|
||||||
setActiveCollection(collection);
|
setActiveCollection(collection);
|
||||||
router.visit(routeWithCollectionId('dashboard', collection.id));
|
router.visit(appendCollectionId(route('dashboard').url, collection.id));
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: compute this in controller
|
// TODO: compute this in controller
|
||||||
@@ -66,7 +67,7 @@ export default function DashboardProviders(
|
|||||||
'OPEN_CREATE_LINK_KEY',
|
'OPEN_CREATE_LINK_KEY',
|
||||||
() =>
|
() =>
|
||||||
router.visit(
|
router.visit(
|
||||||
routeWithCollectionId('link.create-form', activeCollection?.id)
|
appendCollectionId(route('link.create-form').url, activeCollection?.id)
|
||||||
),
|
),
|
||||||
{
|
{
|
||||||
enabled: globalHotkeysEnabled,
|
enabled: globalHotkeysEnabled,
|
||||||
@@ -74,7 +75,7 @@ export default function DashboardProviders(
|
|||||||
);
|
);
|
||||||
useShortcut(
|
useShortcut(
|
||||||
'OPEN_CREATE_COLLECTION_KEY',
|
'OPEN_CREATE_COLLECTION_KEY',
|
||||||
() => router.visit('collection.create-form'),
|
() => router.visit(route('collection.create-form').url),
|
||||||
{
|
{
|
||||||
enabled: globalHotkeysEnabled,
|
enabled: globalHotkeysEnabled,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { useTheme } from '@emotion/react';
|
import { useTheme } from '@emotion/react';
|
||||||
|
import { route } from '@izzyjs/route/client';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { BsThreeDotsVertical } from 'react-icons/bs';
|
import { BsThreeDotsVertical } from 'react-icons/bs';
|
||||||
import { GoPencil } from 'react-icons/go';
|
import { GoPencil } from 'react-icons/go';
|
||||||
@@ -6,7 +7,7 @@ import { IoTrashOutline } from 'react-icons/io5';
|
|||||||
import Dropdown from '~/components/common/dropdown/dropdown';
|
import Dropdown from '~/components/common/dropdown/dropdown';
|
||||||
import { DropdownItemLink } from '~/components/common/dropdown/dropdown_item';
|
import { DropdownItemLink } from '~/components/common/dropdown/dropdown_item';
|
||||||
import FavoriteDropdownItem from '~/components/dashboard/side_nav/favorite/favorite_dropdown_item';
|
import FavoriteDropdownItem from '~/components/dashboard/side_nav/favorite/favorite_dropdown_item';
|
||||||
import { routeWithLinkId } from '~/lib/navigation';
|
import { appendLinkId } from '~/lib/navigation';
|
||||||
import { Link } from '~/types/app';
|
import { Link } from '~/types/app';
|
||||||
|
|
||||||
export default function LinkControls({ link }: { link: Link }) {
|
export default function LinkControls({ link }: { link: Link }) {
|
||||||
@@ -20,11 +21,13 @@ export default function LinkControls({ link }: { link: Link }) {
|
|||||||
svgSize={18}
|
svgSize={18}
|
||||||
>
|
>
|
||||||
<FavoriteDropdownItem link={link} />
|
<FavoriteDropdownItem link={link} />
|
||||||
<DropdownItemLink href={routeWithLinkId('link.edit-form', link.id)}>
|
<DropdownItemLink
|
||||||
|
href={appendLinkId(route('link.edit-form').url, link.id)}
|
||||||
|
>
|
||||||
<GoPencil /> {t('link.edit')}
|
<GoPencil /> {t('link.edit')}
|
||||||
</DropdownItemLink>
|
</DropdownItemLink>
|
||||||
<DropdownItemLink
|
<DropdownItemLink
|
||||||
href={routeWithLinkId('link.delete-form', link.id)}
|
href={appendLinkId(route('link.delete-form').url, link.id)}
|
||||||
danger
|
danger
|
||||||
>
|
>
|
||||||
<IoTrashOutline /> {t('link.delete')}
|
<IoTrashOutline /> {t('link.delete')}
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
import { Link } from '@inertiajs/react';
|
import { Link } from '@inertiajs/react';
|
||||||
|
import { route } from '@izzyjs/route/client';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import useActiveCollection from '~/hooks/use_active_collection';
|
import useActiveCollection from '~/hooks/use_active_collection';
|
||||||
import { routeWithCollectionId } from '~/lib/navigation';
|
import { appendCollectionId } from '~/lib/navigation';
|
||||||
import { fadeIn } from '~/styles/keyframes';
|
import { fadeIn } from '~/styles/keyframes';
|
||||||
|
|
||||||
const NoCollectionStyle = styled.div({
|
const NoCollectionStyle = styled.div({
|
||||||
@@ -29,7 +30,9 @@ export function NoCollection() {
|
|||||||
return (
|
return (
|
||||||
<NoCollectionStyle>
|
<NoCollectionStyle>
|
||||||
<Text>{t('select-collection')}</Text>
|
<Text>{t('select-collection')}</Text>
|
||||||
<Link href={'collection.create-form'}>{t('or-create-one')}</Link>
|
<Link href={route('collection.create-form').url}>
|
||||||
|
{t('or-create-one')}
|
||||||
|
</Link>
|
||||||
</NoCollectionStyle>
|
</NoCollectionStyle>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -51,7 +54,10 @@ export function NoLink() {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Link
|
<Link
|
||||||
href={routeWithCollectionId('link.create-form', activeCollection?.id)}
|
href={appendCollectionId(
|
||||||
|
route('link.create-form').url,
|
||||||
|
activeCollection?.id
|
||||||
|
)}
|
||||||
>
|
>
|
||||||
{t('link.create')}
|
{t('link.create')}
|
||||||
</Link>
|
</Link>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
|
import { route } from '@izzyjs/route/client';
|
||||||
import { FormEvent, useCallback, useEffect, useState } from 'react';
|
import { FormEvent, useCallback, useEffect, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { IoIosSearch } from 'react-icons/io';
|
import { IoIosSearch } from 'react-icons/io';
|
||||||
@@ -10,7 +11,7 @@ import useActiveCollection from '~/hooks/use_active_collection';
|
|||||||
import useCollections from '~/hooks/use_collections';
|
import useCollections from '~/hooks/use_collections';
|
||||||
import useToggle from '~/hooks/use_modal';
|
import useToggle from '~/hooks/use_modal';
|
||||||
import useShortcut from '~/hooks/use_shortcut';
|
import useShortcut from '~/hooks/use_shortcut';
|
||||||
import { tuyau, tuyauAbortController } from '~/lib/tuyau';
|
import { makeRequest } from '~/lib/request';
|
||||||
import { SearchResult } from '~/types/search';
|
import { SearchResult } from '~/types/search';
|
||||||
|
|
||||||
const SearchInput = styled.input(({ theme }) => ({
|
const SearchInput = styled.input(({ theme }) => ({
|
||||||
@@ -77,14 +78,18 @@ function SearchModal({ openItem: OpenItem }: SearchModalProps) {
|
|||||||
return setResults([]);
|
return setResults([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
tuyau.search.$get({ query: { searchTerm } }).then(({ error, data }) => {
|
const controller = new AbortController();
|
||||||
if (error?.status === 404) return setResults([]);
|
const { url, method } = route('search', { qs: { term: searchTerm } });
|
||||||
const results = data?.results || [];
|
makeRequest({
|
||||||
setResults(results);
|
method,
|
||||||
setSelectedItem(results?.[0]);
|
url,
|
||||||
|
controller,
|
||||||
|
}).then(({ results: _results }) => {
|
||||||
|
setResults(_results);
|
||||||
|
setSelectedItem(_results?.[0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
return () => tuyauAbortController.abort();
|
return () => controller.abort();
|
||||||
}, [searchTerm]);
|
}, [searchTerm]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
|
import { route } from '@izzyjs/route/client';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { BsThreeDotsVertical } from 'react-icons/bs';
|
import { BsThreeDotsVertical } from 'react-icons/bs';
|
||||||
import { FaRegEye } from 'react-icons/fa';
|
import { FaRegEye } from 'react-icons/fa';
|
||||||
@@ -11,7 +12,7 @@ import TextEllipsis from '~/components/common/text_ellipsis';
|
|||||||
import LinkFavicon from '~/components/dashboard/link/link_favicon';
|
import LinkFavicon from '~/components/dashboard/link/link_favicon';
|
||||||
import FavoriteDropdownItem from '~/components/dashboard/side_nav/favorite/favorite_dropdown_item';
|
import FavoriteDropdownItem from '~/components/dashboard/side_nav/favorite/favorite_dropdown_item';
|
||||||
import { ItemExternalLink } from '~/components/dashboard/side_nav/nav_item';
|
import { ItemExternalLink } from '~/components/dashboard/side_nav/nav_item';
|
||||||
import { routeWithCollectionId, routeWithLinkId } from '~/lib/navigation';
|
import { appendCollectionId, appendLinkId } from '~/lib/navigation';
|
||||||
import { LinkWithCollection } from '~/types/app';
|
import { LinkWithCollection } from '~/types/app';
|
||||||
|
|
||||||
const FavoriteItemStyle = styled(ItemExternalLink)(({ theme }) => ({
|
const FavoriteItemStyle = styled(ItemExternalLink)(({ theme }) => ({
|
||||||
@@ -46,16 +47,18 @@ export default function FavoriteItem({ link }: { link: LinkWithCollection }) {
|
|||||||
svgSize={18}
|
svgSize={18}
|
||||||
>
|
>
|
||||||
<DropdownItemLink
|
<DropdownItemLink
|
||||||
href={routeWithCollectionId('dashboard', link.collection.id)}
|
href={appendCollectionId(route('dashboard').url, link.collection.id)}
|
||||||
>
|
>
|
||||||
<FaRegEye /> {t('go-to-collection')}
|
<FaRegEye /> {t('go-to-collection')}
|
||||||
</DropdownItemLink>
|
</DropdownItemLink>
|
||||||
<FavoriteDropdownItem link={link} />
|
<FavoriteDropdownItem link={link} />
|
||||||
<DropdownItemLink href={routeWithLinkId('link.edit-form', link.id)}>
|
<DropdownItemLink
|
||||||
|
href={appendLinkId(route('link.edit-form').url, link.id)}
|
||||||
|
>
|
||||||
<GoPencil /> {t('link.edit')}
|
<GoPencil /> {t('link.edit')}
|
||||||
</DropdownItemLink>
|
</DropdownItemLink>
|
||||||
<DropdownItemLink
|
<DropdownItemLink
|
||||||
href={routeWithLinkId('link.delete-form', link.id)}
|
href={appendLinkId(route('link.delete-form').url, link.id)}
|
||||||
danger
|
danger
|
||||||
>
|
>
|
||||||
<IoTrashOutline /> {t('link.delete')}
|
<IoTrashOutline /> {t('link.delete')}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
|
import { route } from '@izzyjs/route/client';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { AiOutlineFolderAdd } from 'react-icons/ai';
|
import { AiOutlineFolderAdd } from 'react-icons/ai';
|
||||||
import { IoAdd, IoShieldHalfSharp } from 'react-icons/io5';
|
import { IoAdd, IoShieldHalfSharp } from 'react-icons/io5';
|
||||||
@@ -10,7 +11,7 @@ import ModalSettings from '~/components/settings/settings_modal';
|
|||||||
import useActiveCollection from '~/hooks/use_active_collection';
|
import useActiveCollection from '~/hooks/use_active_collection';
|
||||||
import useUser from '~/hooks/use_user';
|
import useUser from '~/hooks/use_user';
|
||||||
import { rgba } from '~/lib/color';
|
import { rgba } from '~/lib/color';
|
||||||
import { getPath, routeWithCollectionId } from '~/lib/navigation';
|
import { appendCollectionId } from '~/lib/navigation';
|
||||||
|
|
||||||
const SideMenu = styled.nav(({ theme }) => ({
|
const SideMenu = styled.nav(({ theme }) => ({
|
||||||
height: '100%',
|
height: '100%',
|
||||||
@@ -55,18 +56,21 @@ export default function SideNavigation() {
|
|||||||
<div css={{ paddingInline: '10px' }}>
|
<div css={{ paddingInline: '10px' }}>
|
||||||
<UserCard />
|
<UserCard />
|
||||||
{user!.isAdmin && (
|
{user!.isAdmin && (
|
||||||
<AdminButton href={getPath('admin.dashboard')}>
|
<AdminButton href={route('admin.dashboard').url}>
|
||||||
<IoShieldHalfSharp /> {t('admin')}
|
<IoShieldHalfSharp /> {t('admin')}
|
||||||
</AdminButton>
|
</AdminButton>
|
||||||
)}
|
)}
|
||||||
<ModalSettings openItem={SettingsButton} />
|
<ModalSettings openItem={SettingsButton} />
|
||||||
<SearchModal openItem={SearchButton} />
|
<SearchModal openItem={SearchButton} />
|
||||||
<AddButton
|
<AddButton
|
||||||
href={routeWithCollectionId('link.create-form', activeCollection?.id)}
|
href={appendCollectionId(
|
||||||
|
route('link.create-form').url,
|
||||||
|
activeCollection?.id
|
||||||
|
)}
|
||||||
>
|
>
|
||||||
<IoAdd /> {t('link.create')}
|
<IoAdd /> {t('link.create')}
|
||||||
</AddButton>
|
</AddButton>
|
||||||
<AddButton href={getPath('collection.create-form')}>
|
<AddButton href={route('collection.create-form').url}>
|
||||||
<AiOutlineFolderAdd /> {t('collection.create')}
|
<AiOutlineFolderAdd /> {t('collection.create')}
|
||||||
</AddButton>
|
</AddButton>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import PATHS from '#constants/paths';
|
import PATHS from '#constants/paths';
|
||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
import { Link } from '@inertiajs/react';
|
import { Link } from '@inertiajs/react';
|
||||||
|
import { route } from '@izzyjs/route/client';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import ExternalLink from '~/components/common/external_link';
|
import ExternalLink from '~/components/common/external_link';
|
||||||
import { getPath } from '~/lib/navigation';
|
|
||||||
import packageJson from '../../../package.json';
|
import packageJson from '../../../package.json';
|
||||||
|
|
||||||
const FooterStyle = styled.footer(({ theme }) => ({
|
const FooterStyle = styled.footer(({ theme }) => ({
|
||||||
@@ -22,9 +22,9 @@ export default function Footer({ className }: { className?: string }) {
|
|||||||
return (
|
return (
|
||||||
<FooterStyle className={className}>
|
<FooterStyle className={className}>
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<Link href={getPath('privacy')}>{t('privacy')}</Link>
|
<Link href={route('privacy').url}>{t('privacy')}</Link>
|
||||||
{' • '}
|
{' • '}
|
||||||
<Link href={getPath('terms')}>{t('terms')}</Link>
|
<Link href={route('terms').url}>{t('terms')}</Link>
|
||||||
{' • '}
|
{' • '}
|
||||||
<ExternalLink href={PATHS.EXTENSION}>Extension</ExternalLink>
|
<ExternalLink href={PATHS.EXTENSION}>Extension</ExternalLink>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
import { Link } from '@inertiajs/react';
|
import { Link } from '@inertiajs/react';
|
||||||
|
import { route } from '@izzyjs/route/client';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import Quotes from '~/components/quotes';
|
import Quotes from '~/components/quotes';
|
||||||
import { getPath } from '~/lib/navigation';
|
|
||||||
|
|
||||||
const HeroStyle = styled.header(({ theme }) => ({
|
const HeroStyle = styled.header(({ theme }) => ({
|
||||||
height: '250px',
|
height: '250px',
|
||||||
@@ -46,7 +46,9 @@ export default function HeroHeader() {
|
|||||||
<HeroStyle>
|
<HeroStyle>
|
||||||
<HeroTitle>{t('about:hero.title')}</HeroTitle>
|
<HeroTitle>{t('about:hero.title')}</HeroTitle>
|
||||||
<HeroQuote>{t('common:slogan')}</HeroQuote>
|
<HeroQuote>{t('common:slogan')}</HeroQuote>
|
||||||
<LinkButton href={getPath('dashboard')}>{t('about:hero.cta')}</LinkButton>
|
<LinkButton href={route('dashboard').url}>
|
||||||
|
{t('about:hero.cta')}
|
||||||
|
</LinkButton>
|
||||||
</HeroStyle>
|
</HeroStyle>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
import { Head, Link } from '@inertiajs/react';
|
import { Head, Link } from '@inertiajs/react';
|
||||||
|
import { route } from '@izzyjs/route/client';
|
||||||
import { FormEvent, ReactNode } from 'react';
|
import { FormEvent, ReactNode } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import Button from '~/components/common/form/_button';
|
import Button from '~/components/common/form/_button';
|
||||||
import Form from '~/components/common/form/_form';
|
import Form from '~/components/common/form/_form';
|
||||||
import TransitionLayout from '~/components/layouts/_transition_layout';
|
import TransitionLayout from '~/components/layouts/_transition_layout';
|
||||||
import i18n from '~/i18n';
|
import i18n from '~/i18n';
|
||||||
import { routeWithCollectionId } from '~/lib/navigation';
|
import { appendCollectionId } from '~/lib/navigation';
|
||||||
import BaseLayout from './_base_layout';
|
import BaseLayout from './_base_layout';
|
||||||
|
|
||||||
const FormLayoutStyle = styled(TransitionLayout)(({ theme }) => ({
|
const FormLayoutStyle = styled(TransitionLayout)(({ theme }) => ({
|
||||||
@@ -58,7 +59,7 @@ export default function FormLayout({
|
|||||||
</Button>
|
</Button>
|
||||||
</Form>
|
</Form>
|
||||||
{!disableHomeLink && (
|
{!disableHomeLink && (
|
||||||
<Link href={routeWithCollectionId('dashboard', collectionId)}>
|
<Link href={appendCollectionId(route('dashboard').url, collectionId)}>
|
||||||
{t('back-home')}
|
{t('back-home')}
|
||||||
</Link>
|
</Link>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import PATHS from '#constants/paths';
|
import PATHS from '#constants/paths';
|
||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
import { Link } from '@inertiajs/react';
|
import { Link } from '@inertiajs/react';
|
||||||
|
import { route } from '@izzyjs/route/client';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { IoIosLogOut } from 'react-icons/io';
|
import { IoIosLogOut } from 'react-icons/io';
|
||||||
import Dropdown from '~/components/common/dropdown/dropdown';
|
import Dropdown from '~/components/common/dropdown/dropdown';
|
||||||
@@ -13,7 +14,6 @@ import RoundedImage from '~/components/common/rounded_image';
|
|||||||
import UnstyledList from '~/components/common/unstyled/unstyled_list';
|
import UnstyledList from '~/components/common/unstyled/unstyled_list';
|
||||||
import ModalSettings from '~/components/settings/settings_modal';
|
import ModalSettings from '~/components/settings/settings_modal';
|
||||||
import useUser from '~/hooks/use_user';
|
import useUser from '~/hooks/use_user';
|
||||||
import { getPath } from '~/lib/navigation';
|
|
||||||
|
|
||||||
type NavbarListDirection = {
|
type NavbarListDirection = {
|
||||||
right?: boolean;
|
right?: boolean;
|
||||||
@@ -66,7 +66,7 @@ export default function Navbar() {
|
|||||||
<Nav>
|
<Nav>
|
||||||
<NavList>
|
<NavList>
|
||||||
<li>
|
<li>
|
||||||
<Link href={getPath('home')} css={{ fontSize: '24px' }}>
|
<Link href={route('home').url} css={{ fontSize: '24px' }}>
|
||||||
MyLinks
|
MyLinks
|
||||||
</Link>
|
</Link>
|
||||||
</li>
|
</li>
|
||||||
@@ -79,13 +79,13 @@ export default function Navbar() {
|
|||||||
<>
|
<>
|
||||||
{user.isAdmin && (
|
{user.isAdmin && (
|
||||||
<li>
|
<li>
|
||||||
<AdminLink href={getPath('admin.dashboard')}>
|
<AdminLink href={route('admin.dashboard').url}>
|
||||||
{t('admin')}
|
{t('admin')}
|
||||||
</AdminLink>
|
</AdminLink>
|
||||||
</li>
|
</li>
|
||||||
)}
|
)}
|
||||||
<li>
|
<li>
|
||||||
<Link href={getPath('dashboard')}>Dashboard</Link>
|
<Link href={route('dashboard').url}>Dashboard</Link>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<ProfileDropdown />
|
<ProfileDropdown />
|
||||||
@@ -97,7 +97,7 @@ export default function Navbar() {
|
|||||||
<ModalSettings openItem={DropdownItemButtonWithPadding} />
|
<ModalSettings openItem={DropdownItemButtonWithPadding} />
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<Link href={getPath('auth.login')}>{t('login')}</Link>
|
<Link href={route('auth.login').url}>{t('login')}</Link>
|
||||||
</li>
|
</li>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
@@ -124,7 +124,7 @@ function ProfileDropdown() {
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<ModalSettings openItem={DropdownItemButton} />
|
<ModalSettings openItem={DropdownItemButton} />
|
||||||
<DropdownItemLink href={getPath('auth.logout')} danger>
|
<DropdownItemLink href={route('auth.logout').url} danger>
|
||||||
<IoIosLogOut /> {t('logout')}
|
<IoIosLogOut /> {t('logout')}
|
||||||
</DropdownItemLink>
|
</DropdownItemLink>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
import { Link } from '@inertiajs/react';
|
import { Link } from '@inertiajs/react';
|
||||||
|
import { route } from '@izzyjs/route/client';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { Fragment } from 'react';
|
import { Fragment } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
@@ -7,7 +8,6 @@ import RoundedImage from '~/components/common/rounded_image';
|
|||||||
import UnstyledList from '~/components/common/unstyled/unstyled_list';
|
import UnstyledList from '~/components/common/unstyled/unstyled_list';
|
||||||
import { DATE_FORMAT } from '~/constants';
|
import { DATE_FORMAT } from '~/constants';
|
||||||
import useUser from '~/hooks/use_user';
|
import useUser from '~/hooks/use_user';
|
||||||
import { getPath } from '~/lib/navigation';
|
|
||||||
|
|
||||||
const ProfileStyle = styled(UnstyledList)({
|
const ProfileStyle = styled(UnstyledList)({
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
@@ -47,7 +47,7 @@ export default function Profile() {
|
|||||||
alt={avatarLabel}
|
alt={avatarLabel}
|
||||||
title={avatarLabel}
|
title={avatarLabel}
|
||||||
/>
|
/>
|
||||||
<Link href={getPath('auth.logout')}>{t('logout')}</Link>
|
<Link href={route('auth.logout').url}>{t('logout')}</Link>
|
||||||
</Column>
|
</Column>
|
||||||
<Column>
|
<Column>
|
||||||
<Field>
|
<Field>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { usePage } from '@inertiajs/react';
|
import { usePage } from '@inertiajs/react';
|
||||||
|
import { route } from '@izzyjs/route/client';
|
||||||
import { ReactNode, createContext, useEffect, useState } from 'react';
|
import { ReactNode, createContext, useEffect, useState } from 'react';
|
||||||
import { tuyau } from '~/lib/tuyau';
|
import { makeRequest } from '~/lib/request';
|
||||||
|
|
||||||
const LS_KEY = 'dark_theme';
|
const LS_KEY = 'dark_theme';
|
||||||
|
|
||||||
@@ -18,8 +19,13 @@ export default function DarkThemeContextProvider({
|
|||||||
const [isDarkTheme, setDarkTheme] = useState<boolean>(preferDarkTheme);
|
const [isDarkTheme, setDarkTheme] = useState<boolean>(preferDarkTheme);
|
||||||
const toggleDarkTheme = (value: boolean) => {
|
const toggleDarkTheme = (value: boolean) => {
|
||||||
setDarkTheme(value);
|
setDarkTheme(value);
|
||||||
tuyau.user.theme.$post({
|
const { method, url } = route('user.theme');
|
||||||
|
makeRequest({
|
||||||
|
method,
|
||||||
|
url,
|
||||||
|
body: {
|
||||||
preferDarkTheme: value,
|
preferDarkTheme: value,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"role": "Role",
|
"role": "Role",
|
||||||
"created_at": "Created at",
|
"created_at": "Created at",
|
||||||
"last_seen_at": "Last seen at",
|
"updated_at": "Updated at",
|
||||||
"admin": "Administrator",
|
"admin": "Administrator",
|
||||||
"user": "User",
|
"user": "User",
|
||||||
"users": "Users",
|
"users": "Users",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"role": "Rôle",
|
"role": "Rôle",
|
||||||
"created_at": "Création",
|
"created_at": "Création",
|
||||||
"last_seen_at": "Dernière connexion",
|
"updated_at": "Mise à jour",
|
||||||
"admin": "Administrateur",
|
"admin": "Administrateur",
|
||||||
"user": "Utilisateur",
|
"user": "Utilisateur",
|
||||||
"users": "Utilisateurs",
|
"users": "Utilisateurs",
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { tuyau } from '~/lib/tuyau';
|
import { route } from '@izzyjs/route/client';
|
||||||
|
import { makeRequest } from '~/lib/request';
|
||||||
import { Link } from '~/types/app';
|
import { Link } from '~/types/app';
|
||||||
|
|
||||||
export const onFavorite = (
|
export const onFavorite = (
|
||||||
@@ -6,13 +7,15 @@ export const onFavorite = (
|
|||||||
isFavorite: boolean,
|
isFavorite: boolean,
|
||||||
cb: () => void
|
cb: () => void
|
||||||
) => {
|
) => {
|
||||||
tuyau
|
const { url, method } = route('link.toggle-favorite', {
|
||||||
.$route('link.toggle-favorite', {
|
|
||||||
id: linkId.toString(),
|
|
||||||
})
|
|
||||||
.$put({
|
|
||||||
favorite: isFavorite,
|
|
||||||
params: { id: linkId.toString() },
|
params: { id: linkId.toString() },
|
||||||
|
});
|
||||||
|
makeRequest({
|
||||||
|
url,
|
||||||
|
method,
|
||||||
|
body: {
|
||||||
|
favorite: isFavorite,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
.then(() => cb())
|
.then(() => cb())
|
||||||
.catch(console.error);
|
.catch(console.error);
|
||||||
|
|||||||
@@ -1,43 +1,19 @@
|
|||||||
import { tuyau } from '~/lib/tuyau';
|
|
||||||
import { Collection, Link } from '~/types/app';
|
import { Collection, Link } from '~/types/app';
|
||||||
import { RouteName } from '~/types/tuyau';
|
|
||||||
|
|
||||||
export const routeWithCollectionId = (
|
export const appendCollectionId = (
|
||||||
routeName: RouteName,
|
url: string,
|
||||||
collectionId?: Collection['id'] | null | undefined
|
collectionId?: Collection['id'] | null | undefined
|
||||||
) =>
|
) => `${url}${collectionId ? `?collectionId=${collectionId}` : ''}`;
|
||||||
buildUrlWithQueryParams(routeName, {
|
|
||||||
collectionId,
|
|
||||||
});
|
|
||||||
|
|
||||||
export const routeWithLinkId = (
|
export const appendLinkId = (
|
||||||
routeName: RouteName,
|
url: string,
|
||||||
linkId?: Link['id'] | null | undefined
|
linkId?: Link['id'] | null | undefined
|
||||||
) => buildUrlWithQueryParams(routeName, { linkId });
|
) => `${url}${linkId ? `?linkId=${linkId}` : ''}`;
|
||||||
|
|
||||||
export const routeWithResourceId = (
|
export const appendResourceId = (
|
||||||
routeName: RouteName,
|
url: string,
|
||||||
resourceId?: Collection['id'] | Link['id']
|
resourceId?: Collection['id'] | Link['id']
|
||||||
) => `${routeName}${resourceId ? `/${resourceId}` : ''}`;
|
) => `${url}${resourceId ? `/${resourceId}` : ''}`;
|
||||||
|
|
||||||
export function buildUrlWithQueryParams(
|
|
||||||
routeName: RouteName,
|
|
||||||
queryParam: Record<string, string | number | null | undefined>
|
|
||||||
) {
|
|
||||||
const path = tuyau.$route(routeName).path;
|
|
||||||
const [key, value] = Object.entries(queryParam)[0];
|
|
||||||
if (!value) {
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
const searchParams = new URLSearchParams({
|
|
||||||
[key]: value.toString(),
|
|
||||||
});
|
|
||||||
return `${path}?${searchParams}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const getRoute = (routeName: RouteName) => tuyau.$route(routeName);
|
|
||||||
export const getPath = (routeName: RouteName) => getRoute(routeName).path;
|
|
||||||
|
|
||||||
export function isValidHttpUrl(urlParam: string) {
|
export function isValidHttpUrl(urlParam: string) {
|
||||||
let url;
|
let url;
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
/// <reference path="../../adonisrc.ts" />
|
|
||||||
|
|
||||||
import { api } from '#adonisjs/api';
|
|
||||||
import { createTuyau } from '@tuyau/client';
|
|
||||||
|
|
||||||
export const tuyauAbortController = new AbortController();
|
|
||||||
export const tuyau = createTuyau({
|
|
||||||
api,
|
|
||||||
baseUrl: 'http://localhost:3333',
|
|
||||||
signal: tuyauAbortController.signal,
|
|
||||||
});
|
|
||||||
@@ -51,7 +51,7 @@ function AdminDashboard({
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
accessorKey: 'id',
|
accessorKey: 'id',
|
||||||
header: () => (
|
header: (
|
||||||
<>
|
<>
|
||||||
# <span css={{ color: theme.colors.grey }}>({users.length})</span>
|
# <span css={{ color: theme.colors.grey }}>({users.length})</span>
|
||||||
</>
|
</>
|
||||||
@@ -69,8 +69,8 @@ function AdminDashboard({
|
|||||||
cell: (info) => info.getValue(),
|
cell: (info) => info.getValue(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorKey: 'collectionsCount',
|
accessorKey: 'count',
|
||||||
header: () => (
|
header: (
|
||||||
<>
|
<>
|
||||||
{t('common:collection.collections', { count: totalCollections })}{' '}
|
{t('common:collection.collections', { count: totalCollections })}{' '}
|
||||||
<span css={{ color: theme.colors.grey }}>
|
<span css={{ color: theme.colors.grey }}>
|
||||||
@@ -78,17 +78,17 @@ function AdminDashboard({
|
|||||||
</span>
|
</span>
|
||||||
</>
|
</>
|
||||||
),
|
),
|
||||||
cell: (info) => info.getValue(),
|
cell: (info) => (info.getValue() as any)?.collection,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorKey: 'linksCount',
|
accessorKey: 'count',
|
||||||
header: () => (
|
header: (
|
||||||
<>
|
<>
|
||||||
{t('common:link.links', { count: totalLinks })}{' '}
|
{t('common:link.links', { count: totalLinks })}{' '}
|
||||||
<span css={{ color: theme.colors.grey }}>({totalLinks})</span>
|
<span css={{ color: theme.colors.grey }}>({totalLinks})</span>
|
||||||
</>
|
</>
|
||||||
),
|
),
|
||||||
cell: (info: any) => info.getValue(),
|
cell: (info: any) => info.getValue()?.link,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorKey: 'isAdmin',
|
accessorKey: 'isAdmin',
|
||||||
@@ -110,23 +110,12 @@ function AdminDashboard({
|
|||||||
cell: RenderDateCell,
|
cell: RenderDateCell,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorKey: 'lastSeenAt',
|
accessorKey: 'updatedAt',
|
||||||
header: t('admin:last_seen_at'),
|
header: t('admin:updated_at'),
|
||||||
cell: RenderDateCell,
|
cell: RenderDateCell,
|
||||||
},
|
},
|
||||||
] satisfies ColumnDef<UserWithRelationCount>[],
|
] as ColumnDef<UserWithRelationCount>[],
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
return (
|
return <Table columns={columns} data={users} />;
|
||||||
<Table
|
|
||||||
columns={columns}
|
|
||||||
data={users}
|
|
||||||
defaultSorting={[
|
|
||||||
{
|
|
||||||
id: 'lastSeenAt',
|
|
||||||
desc: true,
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { Visibility } from '#enums/visibility';
|
import { Visibility } from '#enums/visibility';
|
||||||
import { useForm } from '@inertiajs/react';
|
import { useForm } from '@inertiajs/react';
|
||||||
|
import { route } from '@izzyjs/route/client';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import FormCollection, {
|
import FormCollection, {
|
||||||
FormCollectionData,
|
FormCollectionData,
|
||||||
} from '~/components/form/form_collection';
|
} from '~/components/form/form_collection';
|
||||||
import { getRoute } from '~/lib/navigation';
|
|
||||||
|
|
||||||
export default function CreateCollectionPage({
|
export default function CreateCollectionPage({
|
||||||
disableHomeLink,
|
disableHomeLink,
|
||||||
@@ -24,8 +24,8 @@ export default function CreateCollectionPage({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const handleSubmit = () => {
|
const handleSubmit = () => {
|
||||||
const { method, path } = getRoute('collection.create');
|
const { method, url } = route('collection.create');
|
||||||
submit(method.at(0) as any, path);
|
submit(method, url);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { useForm } from '@inertiajs/react';
|
import { useForm } from '@inertiajs/react';
|
||||||
|
import { route } from '@izzyjs/route/client';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import FormCollection, {
|
import FormCollection, {
|
||||||
FormCollectionData,
|
FormCollectionData,
|
||||||
} from '~/components/form/form_collection';
|
} from '~/components/form/form_collection';
|
||||||
import { tuyau } from '~/lib/tuyau';
|
|
||||||
import { Collection } from '~/types/app';
|
import { Collection } from '~/types/app';
|
||||||
|
|
||||||
export default function DeleteCollectionPage({
|
export default function DeleteCollectionPage({
|
||||||
@@ -20,10 +20,10 @@ export default function DeleteCollectionPage({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const handleSubmit = () => {
|
const handleSubmit = () => {
|
||||||
const { method, path } = tuyau.$route('collection.delete', {
|
const { method, url } = route('collection.delete', {
|
||||||
id: collection.id.toString(),
|
params: { id: collection.id.toString() },
|
||||||
});
|
});
|
||||||
submit(method.at(0) as any, path);
|
submit(method, url);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { useForm } from '@inertiajs/react';
|
import { useForm } from '@inertiajs/react';
|
||||||
|
import { route } from '@izzyjs/route/client';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import FormCollection, {
|
import FormCollection, {
|
||||||
FormCollectionData,
|
FormCollectionData,
|
||||||
} from '~/components/form/form_collection';
|
} from '~/components/form/form_collection';
|
||||||
import { tuyau } from '~/lib/tuyau';
|
|
||||||
import { Collection } from '~/types/app';
|
import { Collection } from '~/types/app';
|
||||||
|
|
||||||
export default function EditCollectionPage({
|
export default function EditCollectionPage({
|
||||||
@@ -30,10 +30,10 @@ export default function EditCollectionPage({
|
|||||||
}, [data, collection]);
|
}, [data, collection]);
|
||||||
|
|
||||||
const handleSubmit = () => {
|
const handleSubmit = () => {
|
||||||
const { method, path } = tuyau.$route('collection.edit', {
|
const { method, url } = route('collection.edit', {
|
||||||
id: collection.id.toString(),
|
params: { id: collection.id.toString() },
|
||||||
});
|
});
|
||||||
submit(method.at(0) as any, path);
|
submit(method, url);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { useForm } from '@inertiajs/react';
|
import { useForm } from '@inertiajs/react';
|
||||||
|
import { route } from '@izzyjs/route/client';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import FormLink from '~/components/form/form_link';
|
import FormLink from '~/components/form/form_link';
|
||||||
import useSearchParam from '~/hooks/use_search_param';
|
import useSearchParam from '~/hooks/use_search_param';
|
||||||
import { isValidHttpUrl } from '~/lib/navigation';
|
import { isValidHttpUrl } from '~/lib/navigation';
|
||||||
import { tuyau } from '~/lib/tuyau';
|
|
||||||
import { Collection } from '~/types/app';
|
import { Collection } from '~/types/app';
|
||||||
|
|
||||||
export default function CreateLinkPage({
|
export default function CreateLinkPage({
|
||||||
@@ -33,8 +33,8 @@ export default function CreateLinkPage({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const handleSubmit = () => {
|
const handleSubmit = () => {
|
||||||
const { method, path } = tuyau.$route('link.create');
|
const { method, url } = route('link.create');
|
||||||
submit(method.at(0) as any, path);
|
submit(method, url);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { useForm } from '@inertiajs/react';
|
import { useForm } from '@inertiajs/react';
|
||||||
|
import { route } from '@izzyjs/route/client';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import FormLink from '~/components/form/form_link';
|
import FormLink from '~/components/form/form_link';
|
||||||
import { tuyau } from '~/lib/tuyau';
|
|
||||||
import { LinkWithCollection } from '~/types/app';
|
import { LinkWithCollection } from '~/types/app';
|
||||||
|
|
||||||
export default function DeleteLinkPage({ link }: { link: LinkWithCollection }) {
|
export default function DeleteLinkPage({ link }: { link: LinkWithCollection }) {
|
||||||
@@ -15,10 +15,10 @@ export default function DeleteLinkPage({ link }: { link: LinkWithCollection }) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const handleSubmit = () => {
|
const handleSubmit = () => {
|
||||||
const { method, path } = tuyau.$route('link.delete', {
|
const { method, url } = route('link.delete', {
|
||||||
id: link.id.toString(),
|
params: { id: link.id.toString() },
|
||||||
});
|
});
|
||||||
submit(method.at(0) as any, path);
|
submit(method, url);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { useForm } from '@inertiajs/react';
|
import { useForm } from '@inertiajs/react';
|
||||||
|
import { route } from '@izzyjs/route/client';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import FormLink from '~/components/form/form_link';
|
import FormLink from '~/components/form/form_link';
|
||||||
import { isValidHttpUrl } from '~/lib/navigation';
|
import { isValidHttpUrl } from '~/lib/navigation';
|
||||||
import { tuyau } from '~/lib/tuyau';
|
|
||||||
import { Collection, Link } from '~/types/app';
|
import { Collection, Link } from '~/types/app';
|
||||||
|
|
||||||
export default function EditLinkPage({
|
export default function EditLinkPage({
|
||||||
@@ -39,10 +39,10 @@ export default function EditLinkPage({
|
|||||||
}, [data, processing]);
|
}, [data, processing]);
|
||||||
|
|
||||||
const handleSubmit = () => {
|
const handleSubmit = () => {
|
||||||
const { method, path } = tuyau.$route('link.edit', {
|
const { method, url } = route('link.edit', {
|
||||||
id: link.id.toString(),
|
params: { id: link.id.toString() },
|
||||||
});
|
});
|
||||||
submit(method.at(0) as any, path);
|
submit(method, url);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
import { Head, Link } from '@inertiajs/react';
|
import { Head, Link } from '@inertiajs/react';
|
||||||
|
import { route } from '@izzyjs/route/client';
|
||||||
import { ReactNode } from 'react';
|
import { ReactNode } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { FcGoogle } from 'react-icons/fc';
|
import { FcGoogle } from 'react-icons/fc';
|
||||||
import Button from '~/components/common/form/_button';
|
import Button from '~/components/common/form/_button';
|
||||||
import ContentLayout from '~/components/layouts/content_layout';
|
import ContentLayout from '~/components/layouts/content_layout';
|
||||||
import Quotes from '~/components/quotes';
|
import Quotes from '~/components/quotes';
|
||||||
import { getPath } from '~/lib/navigation';
|
|
||||||
|
|
||||||
const LoginContainer = styled.div({
|
const LoginContainer = styled.div({
|
||||||
width: '100%',
|
width: '100%',
|
||||||
@@ -70,14 +70,14 @@ function LoginPage() {
|
|||||||
<FormWrapper>
|
<FormWrapper>
|
||||||
<h1>{t('login:title')}</h1>
|
<h1>{t('login:title')}</h1>
|
||||||
<InformativeText>{t('login:informative-text')}</InformativeText>
|
<InformativeText>{t('login:informative-text')}</InformativeText>
|
||||||
<ButtonLink href={getPath('auth.google')}>
|
<ButtonLink href={route('auth.google').url}>
|
||||||
<FcGoogle size="1.5em" />{' '}
|
<FcGoogle size="1.5em" />{' '}
|
||||||
{t('login:continue-with', { provider: 'Google' })}
|
{t('login:continue-with', { provider: 'Google' })}
|
||||||
</ButtonLink>
|
</ButtonLink>
|
||||||
</FormWrapper>
|
</FormWrapper>
|
||||||
<AgreementText>
|
<AgreementText>
|
||||||
{t('login:accept-terms')}{' '}
|
{t('login:accept-terms')}{' '}
|
||||||
<Link href={getPath('terms')}>{t('common:terms')}</Link>
|
<Link href={route('terms').url}>{t('common:terms')}</Link>
|
||||||
</AgreementText>
|
</AgreementText>
|
||||||
</LoginContainer>
|
</LoginContainer>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { Link } from '@inertiajs/react';
|
import { Link } from '@inertiajs/react';
|
||||||
|
import { route } from '@izzyjs/route/client';
|
||||||
import { ReactNode } from 'react';
|
import { ReactNode } from 'react';
|
||||||
import { Trans, useTranslation } from 'react-i18next';
|
import { Trans, useTranslation } from 'react-i18next';
|
||||||
import LegalContentLayout from '~/components/layouts/legal_content_layout';
|
import LegalContentLayout from '~/components/layouts/legal_content_layout';
|
||||||
import { getPath } from '~/lib/navigation';
|
|
||||||
|
|
||||||
function TermsPage() {
|
function TermsPage() {
|
||||||
const { t } = useTranslation('terms');
|
const { t } = useTranslation('terms');
|
||||||
@@ -30,7 +30,7 @@ function TermsPage() {
|
|||||||
<p>
|
<p>
|
||||||
<Trans
|
<Trans
|
||||||
i18nKey="personal_data.collect.description"
|
i18nKey="personal_data.collect.description"
|
||||||
components={{ a: <Link href={getPath('privacy')} /> }}
|
components={{ a: <Link href={route('privacy').url} /> }}
|
||||||
/>
|
/>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|||||||
7
inertia/types/app.d.ts
vendored
7
inertia/types/app.d.ts
vendored
@@ -24,9 +24,10 @@ type UserWithRelationCount = CommonBase & {
|
|||||||
fullname: string;
|
fullname: string;
|
||||||
avatarUrl: string;
|
avatarUrl: string;
|
||||||
isAdmin: string;
|
isAdmin: string;
|
||||||
linksCount: number;
|
count: {
|
||||||
collectionsCount: number;
|
link: number;
|
||||||
lastSeenAt: string;
|
collection: number;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
type Link = CommonBase & {
|
type Link = CommonBase & {
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
import { api } from '#adonisjs/api';
|
|
||||||
|
|
||||||
export type RouteName = (typeof api)['routes'][number]['name'];
|
|
||||||
54
package.json
54
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "my-links",
|
"name": "my-links",
|
||||||
"version": "2.2.1",
|
"version": "2.1.2",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"license": "UNLICENSED",
|
"license": "UNLICENSED",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -34,8 +34,7 @@
|
|||||||
"#start/*": "./start/*.js",
|
"#start/*": "./start/*.js",
|
||||||
"#config/*": "./config/*.js",
|
"#config/*": "./config/*.js",
|
||||||
"#lib/*": "./app/lib/*.js",
|
"#lib/*": "./app/lib/*.js",
|
||||||
"#types/*": "./app/types/*.js",
|
"#routes/*": "./start/routes/*.js"
|
||||||
"#adonisjs/*": "./.adonisjs/*.js"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@adonisjs/assembler": "^7.8.2",
|
"@adonisjs/assembler": "^7.8.2",
|
||||||
@@ -43,65 +42,64 @@
|
|||||||
"@adonisjs/prettier-config": "^1.4.0",
|
"@adonisjs/prettier-config": "^1.4.0",
|
||||||
"@adonisjs/tsconfig": "^1.4.0",
|
"@adonisjs/tsconfig": "^1.4.0",
|
||||||
"@emotion/babel-plugin": "^11.12.0",
|
"@emotion/babel-plugin": "^11.12.0",
|
||||||
"@faker-js/faker": "^9.1.0",
|
"@faker-js/faker": "^9.0.1",
|
||||||
"@japa/assert": "^3.0.0",
|
"@japa/assert": "^3.0.0",
|
||||||
"@japa/plugin-adonisjs": "^3.0.1",
|
"@japa/plugin-adonisjs": "^3.0.1",
|
||||||
"@japa/runner": "^3.1.4",
|
"@japa/runner": "^3.1.4",
|
||||||
"@swc/core": "^1.7.40",
|
"@swc/core": "^1.7.26",
|
||||||
"@types/luxon": "^3.4.2",
|
"@types/luxon": "^3.4.2",
|
||||||
"@types/node": "^20.14.10",
|
"@types/node": "^20.14.10",
|
||||||
"@types/react": "^18.3.12",
|
"@types/react": "^18.3.7",
|
||||||
"@types/react-dom": "^18.3.1",
|
"@types/react-dom": "^18.3.0",
|
||||||
"@types/react-toggle": "^4.0.5",
|
"@types/react-toggle": "^4.0.5",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.11.0",
|
"@typescript-eslint/eslint-plugin": "^8.6.0",
|
||||||
"@vitejs/plugin-react": "^4.3.3",
|
"@vitejs/plugin-react": "^4.3.1",
|
||||||
"eslint": "^9.13.0",
|
"eslint": "^9.10.0",
|
||||||
"hot-hook": "^0.3.1",
|
"hot-hook": "^0.2.6",
|
||||||
"husky": "^9.1.6",
|
"husky": "^9.1.6",
|
||||||
"lint-staged": "^15.2.10",
|
"lint-staged": "^15.2.10",
|
||||||
"pino-pretty": "^11.3.0",
|
"pino-pretty": "^11.2.2",
|
||||||
"prettier": "^3.3.3",
|
"prettier": "^3.3.3",
|
||||||
"release-it": "^17.10.0",
|
"release-it": "^17.6.0",
|
||||||
"ts-node-maintained": "^10.9.4",
|
"ts-node-maintained": "^10.9.4",
|
||||||
"typescript": "~5.5.4",
|
"typescript": "~5.6.2",
|
||||||
"vite": "^5.4.10"
|
"vite": "^5.4.6"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@adonisjs/ally": "^5.0.2",
|
"@adonisjs/ally": "^5.0.2",
|
||||||
"@adonisjs/auth": "^9.2.3",
|
"@adonisjs/auth": "^9.2.3",
|
||||||
"@adonisjs/core": "^6.14.1",
|
"@adonisjs/core": "^6.13.1",
|
||||||
"@adonisjs/cors": "^2.2.1",
|
"@adonisjs/cors": "^2.2.1",
|
||||||
"@adonisjs/inertia": "^1.2.3",
|
"@adonisjs/inertia": "^1.1.0",
|
||||||
"@adonisjs/lucid": "^21.3.0",
|
"@adonisjs/lucid": "^21.2.0",
|
||||||
"@adonisjs/session": "^7.5.0",
|
"@adonisjs/session": "^7.4.2",
|
||||||
"@adonisjs/shield": "^8.1.1",
|
"@adonisjs/shield": "^8.1.1",
|
||||||
"@adonisjs/static": "^1.1.1",
|
"@adonisjs/static": "^1.1.1",
|
||||||
"@adonisjs/vite": "^3.0.0",
|
"@adonisjs/vite": "^3.0.0",
|
||||||
"@emotion/react": "11.12.0",
|
"@emotion/react": "11.12.0",
|
||||||
"@emotion/styled": "^11.13.0",
|
"@emotion/styled": "^11.13.0",
|
||||||
"@inertiajs/react": "^1.2.0",
|
"@inertiajs/react": "^1.2.0",
|
||||||
|
"@izzyjs/route": "^1.1.0-0",
|
||||||
"@tanstack/react-table": "^8.20.5",
|
"@tanstack/react-table": "^8.20.5",
|
||||||
"@tuyau/client": "^0.1.3",
|
|
||||||
"@tuyau/core": "^0.2.1",
|
|
||||||
"@tuyau/utils": "^0.0.4",
|
|
||||||
"@vinejs/vine": "^2.1.0",
|
"@vinejs/vine": "^2.1.0",
|
||||||
|
"adonisjs-scheduler": "^1.0.5",
|
||||||
"bentocache": "^1.0.0-beta.9",
|
"bentocache": "^1.0.0-beta.9",
|
||||||
"dayjs": "^1.11.13",
|
"dayjs": "^1.11.13",
|
||||||
"edge.js": "^6.2.0",
|
"edge.js": "^6.0.2",
|
||||||
"hex-rgb": "^5.0.0",
|
"hex-rgb": "^5.0.0",
|
||||||
"i18next": "^23.16.4",
|
"i18next": "^23.15.1",
|
||||||
"knex": "^3.1.0",
|
"knex": "^3.1.0",
|
||||||
"luxon": "^3.5.0",
|
"luxon": "^3.5.0",
|
||||||
"node-html-parser": "^6.1.13",
|
"node-html-parser": "^6.1.13",
|
||||||
"pg": "^8.13.1",
|
"pg": "^8.12.0",
|
||||||
"react": "^18.3.1",
|
"react": "^18.3.1",
|
||||||
"react-dnd": "^16.0.1",
|
"react-dnd": "^16.0.1",
|
||||||
"react-dnd-html5-backend": "^16.0.1",
|
"react-dnd-html5-backend": "^16.0.1",
|
||||||
"react-dom": "^18.3.1",
|
"react-dom": "^18.3.1",
|
||||||
"react-hotkeys-hook": "^4.5.1",
|
"react-hotkeys-hook": "^4.5.1",
|
||||||
"react-i18next": "^15.1.0",
|
"react-i18next": "^15.0.2",
|
||||||
"react-icons": "^5.3.0",
|
"react-icons": "^5.3.0",
|
||||||
"react-select": "^5.8.2",
|
"react-select": "^5.8.0",
|
||||||
"react-swipeable": "^7.0.1",
|
"react-swipeable": "^7.0.1",
|
||||||
"react-toggle": "^4.1.3",
|
"react-toggle": "^4.1.3",
|
||||||
"reflect-metadata": "^0.2.2"
|
"reflect-metadata": "^0.2.2"
|
||||||
@@ -116,7 +114,7 @@
|
|||||||
"trailingComma": "es5",
|
"trailingComma": "es5",
|
||||||
"semi": true,
|
"semi": true,
|
||||||
"singleQuote": true,
|
"singleQuote": true,
|
||||||
"useTabs": true,
|
"useTabs": false,
|
||||||
"quoteProps": "as-needed",
|
"quoteProps": "as-needed",
|
||||||
"bracketSpacing": true,
|
"bracketSpacing": true,
|
||||||
"arrowParens": "always",
|
"arrowParens": "always",
|
||||||
|
|||||||
2506
pnpm-lock.yaml
generated
2506
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -1,17 +1,18 @@
|
|||||||
import { getRoute } from '#lib/tuyau';
|
|
||||||
import { QueryParams } from '#types/query_params';
|
|
||||||
import { RouteName, RouteParams } from '#types/tuyau';
|
|
||||||
import { Response } from '@adonisjs/core/http';
|
import { Response } from '@adonisjs/core/http';
|
||||||
|
import { route } from '@izzyjs/route/client';
|
||||||
|
import { RouteName } from '@izzyjs/route/types';
|
||||||
|
|
||||||
type RouteOptions = {
|
type IzzyRouteOptions = {
|
||||||
params?: RouteParams;
|
params?: Record<string, any>; //Params<Name>;
|
||||||
} & QueryParams;
|
qs?: Record<string, any>;
|
||||||
|
prefix?: string;
|
||||||
|
};
|
||||||
|
|
||||||
declare module '@adonisjs/core/http' {
|
declare module '@adonisjs/core/http' {
|
||||||
export interface Response {
|
export interface Response {
|
||||||
redirectToNamedRoute: (
|
redirectToNamedRoute: (
|
||||||
routeName: RouteName,
|
routeName: RouteName,
|
||||||
options?: RouteOptions
|
options?: IzzyRouteOptions
|
||||||
) => void;
|
) => void;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -19,7 +20,12 @@ declare module '@adonisjs/core/http' {
|
|||||||
Response.macro(
|
Response.macro(
|
||||||
'redirectToNamedRoute',
|
'redirectToNamedRoute',
|
||||||
function (this: Response, routeName, options) {
|
function (this: Response, routeName, options) {
|
||||||
const route = getRoute(routeName, options);
|
// TODO: fix this
|
||||||
this.redirect().toRoute(route.path, route.params, options);
|
// @ts-ignore
|
||||||
|
const current = route(routeName, options);
|
||||||
|
this.redirect().toRoute(current.url, current.params, {
|
||||||
|
qs: current.qs,
|
||||||
|
disableRouteLookup: true,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ server.use([
|
|||||||
() => import('@adonisjs/cors/cors_middleware'),
|
() => import('@adonisjs/cors/cors_middleware'),
|
||||||
() => import('@adonisjs/vite/vite_middleware'),
|
() => import('@adonisjs/vite/vite_middleware'),
|
||||||
() => import('@adonisjs/inertia/inertia_middleware'),
|
() => import('@adonisjs/inertia/inertia_middleware'),
|
||||||
|
() => import('@izzyjs/route/izzy_middleware'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,8 +41,6 @@ router.use([
|
|||||||
() => import('@adonisjs/session/session_middleware'),
|
() => import('@adonisjs/session/session_middleware'),
|
||||||
() => import('@adonisjs/shield/shield_middleware'),
|
() => import('@adonisjs/shield/shield_middleware'),
|
||||||
() => import('@adonisjs/auth/initialize_auth_middleware'),
|
() => import('@adonisjs/auth/initialize_auth_middleware'),
|
||||||
() => import('#middleware/silent_auth_middleware'),
|
|
||||||
() => import('#middleware/update_user_last_seen_middleware'),
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import './routes/admin.js';
|
import '#routes/admin';
|
||||||
import './routes/app.js';
|
import '#routes/app';
|
||||||
import './routes/auth.js';
|
import '#routes/auth';
|
||||||
import './routes/collection.js';
|
import '#routes/collection';
|
||||||
import './routes/favicon.js';
|
import '#routes/favicon';
|
||||||
import './routes/link.js';
|
import '#routes/link';
|
||||||
import './routes/search.js';
|
import '#routes/search';
|
||||||
import './routes/shared_collection.js';
|
import '#routes/shared_collection';
|
||||||
|
|||||||
3
start/scheduler.ts
Normal file
3
start/scheduler.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import scheduler from 'adonisjs-scheduler/services/main';
|
||||||
|
|
||||||
|
scheduler.command('remove:inactive-users').cron('0 20 * * *');
|
||||||
6
startup.sh
Executable file
6
startup.sh
Executable file
@@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
(trap 'kill 0' SIGINT; node ace scheduler:run & pnpm start)
|
||||||
|
|
||||||
|
wait -n
|
||||||
|
exit $?
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
import app from '@adonisjs/core/services/app';
|
|
||||||
import testUtils from '@adonisjs/core/services/test_utils';
|
|
||||||
import { assert } from '@japa/assert';
|
import { assert } from '@japa/assert';
|
||||||
import { pluginAdonisJS } from '@japa/plugin-adonisjs';
|
import app from '@adonisjs/core/services/app';
|
||||||
import type { Config } from '@japa/runner/types';
|
import type { Config } from '@japa/runner/types';
|
||||||
|
import { pluginAdonisJS } from '@japa/plugin-adonisjs';
|
||||||
|
import testUtils from '@adonisjs/core/services/test_utils';
|
||||||
|
import { izzyRoutePlugin } from '@izzyjs/route/plugins/japa';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is imported by the "bin/test.ts" entrypoint file
|
* This file is imported by the "bin/test.ts" entrypoint file
|
||||||
@@ -12,7 +13,11 @@ import type { Config } from '@japa/runner/types';
|
|||||||
* Configure Japa plugins in the plugins array.
|
* Configure Japa plugins in the plugins array.
|
||||||
* Learn more - https://japa.dev/docs/runner-config#plugins-optional
|
* Learn more - https://japa.dev/docs/runner-config#plugins-optional
|
||||||
*/
|
*/
|
||||||
export const plugins: Config['plugins'] = [assert(), pluginAdonisJS(app)];
|
export const plugins: Config['plugins'] = [
|
||||||
|
assert(),
|
||||||
|
pluginAdonisJS(app),
|
||||||
|
izzyRoutePlugin(),
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure lifecycle function to run before and after all the
|
* Configure lifecycle function to run before and after all the
|
||||||
|
|||||||
Reference in New Issue
Block a user