create-arkos 2.0.0-next.2 → 2.0.0-next.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +178 -150
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/project-config-inquirer.js +93 -74
- package/dist/utils/project-config-inquirer.js.map +1 -1
- package/dist/utils/template-compiler.js +16 -11
- package/dist/utils/template-compiler.js.map +1 -1
- package/package.json +15 -14
- package/templates/basic/.env.hbs +5 -1
- package/templates/basic/.gitignore.hbs +2 -0
- package/templates/basic/README.md.hbs +2 -4
- package/templates/basic/arkos.config.ts.hbs +16 -3
- package/templates/basic/jsconfig.json.hbs +3 -13
- package/templates/basic/package.json.hbs +33 -18
- package/templates/basic/prisma/schema/__tests__/user-role.prisma.hbs.test.ts +2 -2
- package/templates/basic/prisma/schema/__tests__/user.prisma.hbs.test.ts +2 -2
- package/templates/basic/prisma/schema/auth-permission.prisma.hbs +3 -9
- package/templates/basic/prisma/schema/auth-role.prisma.hbs +2 -2
- package/templates/basic/prisma/schema/schema.prisma.hbs +2 -3
- package/templates/basic/prisma/schema/user-permission.prisma.hbs +18 -0
- package/templates/basic/prisma/schema/user.prisma.hbs +4 -2
- package/templates/basic/prisma.config.ts.hbs +11 -0
- package/templates/basic/public/favicon.ico +0 -0
- package/templates/basic/src/app.ts.hbs +9 -7
- package/templates/basic/src/modules/auth/auth.policy.ts.hbs +1 -1
- package/templates/basic/src/modules/auth/auth.router.ts.hbs +72 -7
- package/templates/basic/src/modules/auth/dtos/login.dto.ts.hbs +1 -1
- package/templates/basic/src/modules/auth/dtos/signup.dto.ts.hbs +1 -1
- package/templates/basic/src/modules/auth/dtos/update-me.dto.ts.hbs +1 -1
- package/templates/basic/src/modules/auth/dtos/update-password.dto.ts.hbs +1 -1
- package/templates/basic/src/modules/auth-permission/auth-permission.router.ts.hbs +39 -7
- package/templates/basic/src/modules/auth-permission/auth-permission.service.ts.hbs +4 -6
- package/templates/basic/src/modules/auth-permission/dtos/create-auth-permission.dto.ts.hbs +7 -10
- package/templates/basic/src/modules/auth-permission/dtos/{query-auth-role.dto.ts.hbs → query-auth-permission.dto.ts.hbs} +1 -1
- package/templates/basic/src/modules/auth-permission/dtos/update-auth-permission.dto.ts.hbs +19 -4
- package/templates/basic/src/modules/auth-role/auth-role.router.ts.hbs +38 -6
- package/templates/basic/src/modules/auth-role/auth-role.service.ts.hbs +4 -6
- package/templates/basic/src/modules/auth-role/dtos/create-auth-role.dto.ts.hbs +3 -8
- package/templates/basic/src/modules/auth-role/dtos/query-auth-role.dto.ts.hbs +1 -1
- package/templates/basic/src/modules/auth-role/dtos/update-auth-role.dto.ts.hbs +3 -6
- package/templates/basic/src/modules/file-upload/file-upload.router.ts.hbs +28 -8
- package/templates/basic/src/modules/user/dtos/create-user.dto.ts.hbs +5 -5
- package/templates/basic/src/modules/user/dtos/update-user.dto.ts.hbs +5 -5
- package/templates/basic/src/modules/user/user.router.ts.hbs +91 -7
- package/templates/basic/src/modules/user/user.service.ts.hbs +4 -6
- package/templates/basic/src/router.ts.hbs +2 -2
- package/templates/basic/src/server.ts.hbs +8 -0
- package/templates/basic/src/utils/prisma/index.ts.hbs +48 -2
- package/templates/basic/src/utils/validation/api-actions.ts.hbs +2 -2
- package/templates/basic/tsconfig.json.hbs +6 -13
- package/templates/basic/src/loadables.ts.hbs +0 -29
- package/templates/basic/src/modules/auth/auth.route-hook.ts.hbs +0 -66
- package/templates/basic/src/modules/auth-permission/auth-permission.route-hook.ts.hbs +0 -35
- package/templates/basic/src/modules/auth-role/auth-role.route-hook.ts.hbs +0 -35
- package/templates/basic/src/modules/file-upload/file-upload.route-hook.ts.hbs +0 -23
- package/templates/basic/src/modules/user/user.route-hook.ts.hbs +0 -88
|
@@ -1,12 +1,32 @@
|
|
|
1
|
-
import { ArkosRouter } from
|
|
2
|
-
{{#if authentication}}
|
|
3
|
-
import fileUploadPolicy from
|
|
1
|
+
import { ArkosRouter, ArkosRouteHook } from 'arkos';
|
|
2
|
+
{{#if (neq authentication.type "none")}}
|
|
3
|
+
import fileUploadPolicy from '@/src/modules/file-upload/file-upload.policy';
|
|
4
4
|
{{/if}}
|
|
5
|
-
import config from
|
|
5
|
+
import config from '@/arkos.config';
|
|
6
6
|
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
7
|
+
const fileUploadRouteHook = ArkosRouteHook("file-upload");
|
|
8
|
+
|
|
9
|
+
fileUploadRouteHook.findFile({
|
|
10
|
+
{{#if (neq authentication.type "none")}}authentication: fileUploadPolicy.View,{{/if}}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
fileUploadRouteHook.uploadFile({
|
|
14
|
+
{{#if (neq authentication.type "none")}}authentication: fileUploadPolicy.Create,{{/if}}
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
fileUploadRouteHook.updateFile({
|
|
18
|
+
{{#if (neq authentication.type "none")}}authentication: fileUploadPolicy.Update,{{/if}}
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
fileUploadRouteHook.deleteFile({
|
|
22
|
+
{{#if (neq authentication.type "none")}}authentication: fileUploadPolicy.Delete,{{/if}}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const fileUploadRouter = ArkosRouter({
|
|
26
|
+
prefix: config?.fileUpload?.baseRoute,
|
|
27
|
+
openapi: { tags: ["File Upload"] },
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
fileUploadRouter.load(fileUploadRouteHook);
|
|
11
31
|
|
|
12
32
|
export default fileUploadRouter;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
{{#if (eq authentication.type "static")}}
|
|
4
4
|
{{#if (neq prisma.provider "sqlite")}}
|
|
5
|
-
import { UserRole } from "
|
|
5
|
+
import { UserRole } from "@/src/generated/prisma/client";
|
|
6
6
|
{{/if}}
|
|
7
7
|
{{/if}}
|
|
8
8
|
|
|
@@ -20,9 +20,9 @@ const CreateUserDto = z.object({
|
|
|
20
20
|
role: z.string(),
|
|
21
21
|
{{else}}
|
|
22
22
|
{{#if authentication.multipleRoles}}
|
|
23
|
-
roles: z.array(z.
|
|
23
|
+
roles: z.array(z.enum(UserRole)),
|
|
24
24
|
{{else}}
|
|
25
|
-
role: z.
|
|
25
|
+
role: z.enum(UserRole),
|
|
26
26
|
{{/if}}
|
|
27
27
|
{{/if}}
|
|
28
28
|
{{else}}
|
|
@@ -40,7 +40,7 @@ const CreateUserDto = z.object({
|
|
|
40
40
|
|
|
41
41
|
export default CreateUserDto;
|
|
42
42
|
{{#if typescript}}
|
|
43
|
-
export type
|
|
43
|
+
export type CreateUserDto = z.infer<typeof CreateUserDto>;
|
|
44
44
|
{{/if}}
|
|
45
45
|
{{/if}}
|
|
46
46
|
{{#if (eq validation.type "class-validator")}}
|
|
@@ -59,7 +59,7 @@ import {
|
|
|
59
59
|
import { Type } from "class-transformer";
|
|
60
60
|
{{#if (eq authentication.type "static")}}
|
|
61
61
|
{{#if (neq prisma.provider "sqlite")}}
|
|
62
|
-
import { UserRole } from "
|
|
62
|
+
import { UserRole } from "@/src/generated/prisma/client";
|
|
63
63
|
{{/if}}
|
|
64
64
|
{{/if}}
|
|
65
65
|
{{#if (eq authentication.type "dynamic")}}
|
|
@@ -3,7 +3,7 @@ import { z } from "zod";
|
|
|
3
3
|
import apiActions from "@/src/utils/validation/api-actions";
|
|
4
4
|
{{#if (eq authentication.type "static")}}
|
|
5
5
|
{{#if (neq prisma.provider "sqlite")}}
|
|
6
|
-
import { UserRole } from "
|
|
6
|
+
import { UserRole } from "@/src/generated/prisma/client";
|
|
7
7
|
{{/if}}
|
|
8
8
|
{{/if}}
|
|
9
9
|
|
|
@@ -22,9 +22,9 @@ const UpdateUserDto = z.object({
|
|
|
22
22
|
role: z.string().optional(),
|
|
23
23
|
{{else}}
|
|
24
24
|
{{#if authentication.multipleRoles}}
|
|
25
|
-
roles: z.array(z.
|
|
25
|
+
roles: z.array(z.enum(UserRole)).optional(),
|
|
26
26
|
{{else}}
|
|
27
|
-
role: z.
|
|
27
|
+
role: z.enum(UserRole).optional(),
|
|
28
28
|
{{/if}}
|
|
29
29
|
{{/if}}
|
|
30
30
|
{{else}}
|
|
@@ -46,7 +46,7 @@ const UpdateUserDto = z.object({
|
|
|
46
46
|
|
|
47
47
|
export default UpdateUserDto;
|
|
48
48
|
{{#if typescript}}
|
|
49
|
-
export type
|
|
49
|
+
export type UpdateUserDto = z.infer<typeof UpdateUserDto>;
|
|
50
50
|
{{/if}}
|
|
51
51
|
{{/if}}
|
|
52
52
|
{{#if (eq validation.type "class-validator")}}
|
|
@@ -66,7 +66,7 @@ import { Type } from 'class-transformer';
|
|
|
66
66
|
import apiActions from "@/src/utils/validation/api-actions";
|
|
67
67
|
{{#if (eq authentication.type "static")}}
|
|
68
68
|
{{#if (neq prisma.provider "sqlite")}}
|
|
69
|
-
import { UserRole } from "
|
|
69
|
+
import { UserRole } from "@/src/generated/prisma/client";
|
|
70
70
|
{{/if}}
|
|
71
71
|
{{/if}}
|
|
72
72
|
{{#if (eq authentication.type "dynamic")}}
|
|
@@ -1,11 +1,95 @@
|
|
|
1
|
-
import { ArkosRouter } from
|
|
2
|
-
{{#if authentication}}
|
|
3
|
-
import userPolicy from
|
|
1
|
+
import { ArkosRouter, ArkosRouteHook } from 'arkos';
|
|
2
|
+
{{#if (neq authentication.type "none")}}
|
|
3
|
+
import userPolicy from '@/src/modules/user/user.policy';
|
|
4
4
|
{{/if}}
|
|
5
|
+
{{#if validation.type}}
|
|
6
|
+
import CreateUserDto from '@/src/modules/user/dtos/create-user.dto';
|
|
7
|
+
import UpdateUserDto from '@/src/modules/user/dtos/update-user.dto';
|
|
8
|
+
{{/if}}
|
|
9
|
+
|
|
10
|
+
const userRouteHook = ArkosRouteHook("user");
|
|
11
|
+
|
|
12
|
+
userRouteHook.createOne({
|
|
13
|
+
{{#if validation.type}}validation: { body: CreateUserDto },{{/if}}
|
|
14
|
+
{{#if (neq authentication.type "none")}}authentication: userPolicy.Create,{{/if}}
|
|
15
|
+
prismaArgs: {
|
|
16
|
+
omit: { password: true },
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
userRouteHook.findOne({
|
|
21
|
+
{{#if (neq authentication.type "none")}}authentication: userPolicy.View,{{/if}}
|
|
22
|
+
prismaArgs: {
|
|
23
|
+
omit: { password: true },
|
|
24
|
+
{{#if (eq authentication.type "dynamic")}}
|
|
25
|
+
include: {
|
|
26
|
+
{{#if authentication.multipleRoles}}
|
|
27
|
+
roles: {
|
|
28
|
+
include: {
|
|
29
|
+
role: {
|
|
30
|
+
include: {
|
|
31
|
+
permissions: true,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
{{else}}
|
|
37
|
+
role: {
|
|
38
|
+
include: {
|
|
39
|
+
role: {
|
|
40
|
+
include: {
|
|
41
|
+
permissions: true,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
{{/if}}
|
|
47
|
+
},
|
|
48
|
+
{{/if}}
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
userRouteHook.findMany({
|
|
53
|
+
{{#if (neq authentication.type "none")}}authentication: userPolicy.View,{{/if}}
|
|
54
|
+
prismaArgs: {
|
|
55
|
+
omit: { password: true },
|
|
56
|
+
{{#if (eq authentication.type "dynamic")}}
|
|
57
|
+
include: {
|
|
58
|
+
{{#if authentication.multipleRoles}}
|
|
59
|
+
roles: {
|
|
60
|
+
include: {
|
|
61
|
+
role: true,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
{{else}}
|
|
65
|
+
role: {
|
|
66
|
+
include: {
|
|
67
|
+
role: true,
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
{{/if}}
|
|
71
|
+
},
|
|
72
|
+
{{/if}}
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
userRouteHook.updateOne({
|
|
77
|
+
{{#if validation.type}}validation: { body: UpdateUserDto },{{/if}}
|
|
78
|
+
{{#if (neq authentication.type "none")}}authentication: userPolicy.Update,{{/if}}
|
|
79
|
+
prismaArgs: {
|
|
80
|
+
omit: { password: true },
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
userRouteHook.deleteOne({
|
|
85
|
+
{{#if (neq authentication.type "none")}}authentication: userPolicy.Delete,{{/if}}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
const userRouter = ArkosRouter({
|
|
89
|
+
prefix: "/users",
|
|
90
|
+
openapi: { tags: ["Users"] },
|
|
91
|
+
});
|
|
5
92
|
|
|
6
|
-
|
|
7
|
-
prefix: "/users",
|
|
8
|
-
openapi: { tags: ["Users"] }
|
|
9
|
-
});
|
|
93
|
+
userRouter.load(userRouteHook);
|
|
10
94
|
|
|
11
95
|
export default userRouter;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
{{#if typescript}}
|
|
3
|
-
import { Prisma } from "@prisma/client"
|
|
1
|
+
import { ArkosPrismaService } from "arkos/services";
|
|
4
2
|
|
|
5
|
-
|
|
3
|
+
{{#if typescript}}
|
|
4
|
+
class UserService extends ArkosPrismaService<"user"> {}
|
|
6
5
|
{{else}}
|
|
7
|
-
|
|
8
|
-
class UserService extends BaseService {}
|
|
6
|
+
class UserService extends ArkosPrismaService {}
|
|
9
7
|
{{/if}}
|
|
10
8
|
|
|
11
9
|
const userService = new UserService("user");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ArkosRouter } from "arkos";
|
|
2
2
|
import fileUploadRouter from "@/src/modules/file-upload/file-upload.router";
|
|
3
|
-
{{#if authentication.type}}
|
|
3
|
+
{{#if (neq authentication.type "none")}}
|
|
4
4
|
import authRouter from "@/src/modules/auth/auth.router";
|
|
5
5
|
import userRouter from "@/src/modules/user/user.router";
|
|
6
6
|
{{/if}}
|
|
@@ -12,7 +12,7 @@ import authPermissionRouter from "@/src/modules/auth-permission/auth-permission.
|
|
|
12
12
|
const router = ArkosRouter();
|
|
13
13
|
|
|
14
14
|
router.use(fileUploadRouter);
|
|
15
|
-
{{#if authentication.type}}
|
|
15
|
+
{{#if (neq authentication.type "none")}}
|
|
16
16
|
router.use(userRouter);
|
|
17
17
|
router.use(authRouter);
|
|
18
18
|
{{/if}}
|
|
@@ -1,5 +1,51 @@
|
|
|
1
|
-
|
|
1
|
+
{{#if (eq prisma.provider "postgresql")}}
|
|
2
|
+
import { PrismaClient } from "@/src/generated/prisma/client";
|
|
3
|
+
import { PrismaPg } from "@prisma/adapter-pg";
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
const adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL{{#if typescript}} as string{{/if}} });
|
|
6
|
+
export const prisma = new PrismaClient({ adapter });
|
|
7
|
+
{{/if}}
|
|
8
|
+
{{#if (eq prisma.provider "cockroachdb")}}
|
|
9
|
+
import { PrismaClient } from "@/src/generated/prisma/client";
|
|
10
|
+
import { PrismaPg } from "@prisma/adapter-pg";
|
|
11
|
+
|
|
12
|
+
// CockroachDB uses the PostgreSQL wire protocol, so it shares the pg adapter
|
|
13
|
+
const adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL{{#if typescript}} as string{{/if}} });
|
|
14
|
+
export const prisma = new PrismaClient({ adapter });
|
|
15
|
+
{{/if}}
|
|
16
|
+
{{#if (eq prisma.provider "mysql")}}
|
|
17
|
+
import { PrismaClient } from "@/src/generated/prisma/client";
|
|
18
|
+
import { PrismaMariaDb } from "@prisma/adapter-mariadb";
|
|
19
|
+
|
|
20
|
+
const dbUrl = new URL(process.env.DATABASE_URL{{#if typescript}} as string{{/if}});
|
|
21
|
+
const adapter = new PrismaMariaDb({
|
|
22
|
+
host: dbUrl.hostname,
|
|
23
|
+
port: Number(dbUrl.port) || 3306,
|
|
24
|
+
user: decodeURIComponent(dbUrl.username),
|
|
25
|
+
password: decodeURIComponent(dbUrl.password),
|
|
26
|
+
database: dbUrl.pathname.replace(/^\//, ""),
|
|
27
|
+
connectionLimit: 5,
|
|
28
|
+
});
|
|
29
|
+
export const prisma = new PrismaClient({ adapter });
|
|
30
|
+
{{/if}}
|
|
31
|
+
{{#if (eq prisma.provider "sqlite")}}
|
|
32
|
+
import { PrismaClient } from "@/src/generated/prisma/client";
|
|
33
|
+
import { PrismaBetterSqlite3 } from "@prisma/adapter-better-sqlite3";
|
|
34
|
+
|
|
35
|
+
const adapter = new PrismaBetterSqlite3({
|
|
36
|
+
url: process.env.DATABASE_URL || "file:./dev.db",
|
|
37
|
+
});
|
|
38
|
+
export const prisma = new PrismaClient({ adapter });
|
|
39
|
+
{{/if}}
|
|
40
|
+
{{#if (eq prisma.provider "sqlserver")}}
|
|
41
|
+
import { PrismaClient } from "@/src/generated/prisma/client";
|
|
42
|
+
import { PrismaMssql } from "@prisma/adapter-mssql";
|
|
43
|
+
|
|
44
|
+
const adapter = new PrismaMssql(process.env.DATABASE_URL{{#if typescript}} as string{{/if}});
|
|
45
|
+
export const prisma = new PrismaClient({ adapter });
|
|
46
|
+
{{/if}}
|
|
47
|
+
{{#if (eq prisma.provider "none")}}
|
|
48
|
+
export const prisma = null;
|
|
49
|
+
{{/if}}
|
|
4
50
|
|
|
5
51
|
export default prisma;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A simple array of available `apiAction` field when using auto generate API (That uses
|
|
2
|
+
* A simple array of available `apiAction` field when using auto generate API (That uses ArkosPrismaService)
|
|
3
3
|
* class behind the scenes.
|
|
4
4
|
*
|
|
5
5
|
* Is worth mentioning that this will be addded into `arkos` as an util.
|
|
6
6
|
*
|
|
7
|
-
* @see {@link https://www.arkosjs.com/docs/
|
|
7
|
+
* @see {@link https://www.arkosjs.com/docs/core-concepts/prisma-orm/handling-relations}
|
|
8
8
|
*/
|
|
9
9
|
const apiActions = ["connect", "disconnect", "delete", "update", "create"]{{#if typescript}} as const{{/if}};
|
|
10
10
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"target": "
|
|
4
|
-
"module": "
|
|
3
|
+
"target": "es2022",
|
|
4
|
+
"module": "es2022",
|
|
5
5
|
"moduleResolution": "bundler",
|
|
6
6
|
"rootDir": ".",
|
|
7
7
|
"baseUrl": ".",
|
|
@@ -15,19 +15,12 @@
|
|
|
15
15
|
"lib": ["es6", "dom"],
|
|
16
16
|
"noImplicitAny": true,
|
|
17
17
|
"paths": {
|
|
18
|
-
"@/*": ["./*"]
|
|
18
|
+
"@/*": ["./*"],
|
|
19
|
+
"@arkosjs/generated": ["./.arkos/index.d.ts"]
|
|
19
20
|
}
|
|
20
21
|
},
|
|
21
|
-
"include": ["src/**/*.ts", "
|
|
22
|
-
"exclude": [
|
|
23
|
-
"**/node_modules",
|
|
24
|
-
"node_modules",
|
|
25
|
-
".build",
|
|
26
|
-
"build",
|
|
27
|
-
"temp",
|
|
28
|
-
"dist",
|
|
29
|
-
"uploads"
|
|
30
|
-
],
|
|
22
|
+
"include": ["src/**/*.ts", "src/**/*.js", "src/**/*.tsx", "src/**/*.jsx", "arkos.config.ts"],
|
|
23
|
+
"exclude": ["node_modules", ".build", "src/**/__tests__/**", "src/**/*.test", "src/**/*.spec", "temp", "dist", "build", "uploads", "src/generated", ".arkos"],
|
|
31
24
|
"watchOptions": {
|
|
32
25
|
"excludeDirectories": ["**/node_modules", "node_modules"]
|
|
33
26
|
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
{{#if typescript}}
|
|
2
|
-
import { ArkosLoadable } from "arkos";
|
|
3
|
-
{{/if}}
|
|
4
|
-
import fileUploadRouteHook from "@/src/modules/file-upload/file-upload.route-hook";
|
|
5
|
-
{{#if authentication.type}}
|
|
6
|
-
import userRouteHook from "@/src/modules/user/user.route-hook";
|
|
7
|
-
import authRouteHook from "@/src/modules/auth/auth.route-hook";
|
|
8
|
-
{{/if}}
|
|
9
|
-
{{#if (eq authentication.type "dynamic")}}
|
|
10
|
-
import authRoleRouteHook from "@/src/modules/auth-role/auth-role.route-hook";
|
|
11
|
-
import authPermissionRouteHook from "@/src/modules/auth-permission/auth-permission.route-hook";
|
|
12
|
-
{{/if}}
|
|
13
|
-
|
|
14
|
-
{{#if typescript}}
|
|
15
|
-
{{else}}
|
|
16
|
-
/** @type import("arkos").ArkosLoadable */
|
|
17
|
-
{{/if}}
|
|
18
|
-
const loadables{{#if typescript}}: ArkosLoadable[]{{/if}} = [
|
|
19
|
-
fileUploadRouteHook,
|
|
20
|
-
{{#if authentication.type}}
|
|
21
|
-
userRouteHook,
|
|
22
|
-
authRouteHook,
|
|
23
|
-
{{/if}}
|
|
24
|
-
{{#if (eq authentication.type "dynamic")}}
|
|
25
|
-
authRoleRouteHook,
|
|
26
|
-
authPermissionRouteHook,
|
|
27
|
-
{{/if}}
|
|
28
|
-
]
|
|
29
|
-
export default loadables;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { ArkosRouteHook } from 'arkos';
|
|
2
|
-
{{#if validation.type}}
|
|
3
|
-
import LoginDto from '@/src/modules/auth/dtos/login.dto';
|
|
4
|
-
import SignupDto from '@/src/modules/auth/dtos/signup.dto';
|
|
5
|
-
import UpdateMeDto from '@/src/modules/auth/dtos/update-me.dto';
|
|
6
|
-
import UpdatePasswordDto from '@/src/modules/auth/dtos/update-password.dto';
|
|
7
|
-
{{/if}}
|
|
8
|
-
|
|
9
|
-
const authRouteHook = ArkosRouteHook("auth");
|
|
10
|
-
|
|
11
|
-
authRouteHook.login({
|
|
12
|
-
{{#if validation.type}}validation: { body: LoginDto },{{/if}}
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
authRouteHook.signup({
|
|
16
|
-
{{#if validation.type}}validation: { body: SignupDto },{{/if}}
|
|
17
|
-
prismaArgs: {
|
|
18
|
-
omit: { password: true },
|
|
19
|
-
},
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
authRouteHook.getMe({
|
|
23
|
-
prismaArgs: {
|
|
24
|
-
omit: { password: true },
|
|
25
|
-
{{#if (eq authentication.type "dynamic")}}
|
|
26
|
-
include: {
|
|
27
|
-
{{#if authentication.multipleRoles}}
|
|
28
|
-
roles: {
|
|
29
|
-
include: {
|
|
30
|
-
role: {
|
|
31
|
-
include: {
|
|
32
|
-
permissions: true,
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
{{else}}
|
|
38
|
-
role: {
|
|
39
|
-
include: {
|
|
40
|
-
role: {
|
|
41
|
-
include: {
|
|
42
|
-
permissions: true,
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
{{/if}}
|
|
48
|
-
},
|
|
49
|
-
{{/if}}
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
authRouteHook.updateMe({
|
|
54
|
-
{{#if validation.type}}validation: { body: UpdateMeDto },{{/if}}
|
|
55
|
-
prismaArgs: {
|
|
56
|
-
omit: { password: true },
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
authRouteHook.updatePassword({
|
|
61
|
-
{{#if validation.type}}validation: { body: UpdatePasswordDto },{{/if}}
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
authRouteHook.logout({});
|
|
65
|
-
|
|
66
|
-
export default authRouteHook;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { ArkosRouteHook } from 'arkos';
|
|
2
|
-
{{#if authentication}}
|
|
3
|
-
import authPermissionPolicy from '@/src/modules/auth-permission/auth-permission.policy';
|
|
4
|
-
{{/if}}
|
|
5
|
-
{{#if validation.type}}
|
|
6
|
-
import CreateAuthPermissionDto from '@/src/modules/auth-permission/dtos/create-auth-permission.dto';
|
|
7
|
-
import UpdateAuthPermissionDto from '@/src/modules/auth-permission/dtos/update-auth-permission.dto';
|
|
8
|
-
import QueryAuthPermissionDto from '@/src/modules/auth-permission/dtos/query-auth-permission.dto';
|
|
9
|
-
{{/if}}
|
|
10
|
-
const authPermissionRouteHook = ArkosRouteHook("auth-permission");
|
|
11
|
-
|
|
12
|
-
authPermissionRouteHook.createOne({
|
|
13
|
-
{{#if validation.type}}validation: { body: CreateAuthPermissionDto },{{/if}}
|
|
14
|
-
{{#if authentication}}authentication: authPermissionPolicy.Create,{{/if}}
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
authPermissionRouteHook.findOne({
|
|
18
|
-
{{#if authentication}}authentication: authPermissionPolicy.View,{{/if}}
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
authPermissionRouteHook.findMany({
|
|
22
|
-
{{#if validation.type}}validation: { query: QueryAuthPermissionDto },{{/if}}
|
|
23
|
-
{{#if authentication}}authentication: authPermissionPolicy.View,{{/if}}
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
authPermissionRouteHook.updateOne({
|
|
27
|
-
{{#if validation.type}}validation: { body: UpdateAuthPermissionDto },{{/if}}
|
|
28
|
-
{{#if authentication}}authentication: authPermissionPolicy.Update,{{/if}}
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
authPermissionRouteHook.deleteOne({
|
|
32
|
-
{{#if authentication}}authentication: authPermissionPolicy.Delete,{{/if}}
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
export default authPermissionRouteHook;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { ArkosRouteHook } from 'arkos';
|
|
2
|
-
{{#if authentication}}
|
|
3
|
-
import authRolePolicy from '@/src/modules/auth-role/auth-role.policy';
|
|
4
|
-
{{/if}}
|
|
5
|
-
{{#if validation.type}}
|
|
6
|
-
import CreateAuthRoleDto from '@/src/modules/auth-role/dtos/create-auth-role.dto';
|
|
7
|
-
import UpdateAuthRoleDto from '@/src/modules/auth-role/dtos/update-auth-role.dto';
|
|
8
|
-
import QueryAuthRoleDto from '@/src/modules/auth-role/dtos/query-auth-role.dto';
|
|
9
|
-
{{/if}}
|
|
10
|
-
const authRoleRouteHook = ArkosRouteHook("auth-role");
|
|
11
|
-
|
|
12
|
-
authRoleRouteHook.createOne({
|
|
13
|
-
{{#if validation.type}}validation: { body: CreateAuthRoleDto },{{/if}}
|
|
14
|
-
{{#if authentication}}authentication: authRolePolicy.Create,{{/if}}
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
authRoleRouteHook.findOne({
|
|
18
|
-
{{#if authentication}}authentication: authRolePolicy.View,{{/if}}
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
authRoleRouteHook.findMany({
|
|
22
|
-
{{#if validation.type}}validation: { query: QueryAuthRoleDto },{{/if}}
|
|
23
|
-
{{#if authentication}}authentication: authRolePolicy.View,{{/if}}
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
authRoleRouteHook.updateOne({
|
|
27
|
-
{{#if validation.type}}validation: { body: UpdateAuthRoleDto },{{/if}}
|
|
28
|
-
{{#if authentication}}authentication: authRolePolicy.Update,{{/if}}
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
authRoleRouteHook.deleteOne({
|
|
32
|
-
{{#if authentication}}authentication: authRolePolicy.Delete,{{/if}}
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
export default authRoleRouteHook;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { ArkosRouteHook } from 'arkos';
|
|
2
|
-
{{#if authentication}}
|
|
3
|
-
import fileUploadPolicy from '@/src/modules/file-upload/file-upload.policy';
|
|
4
|
-
{{/if}}
|
|
5
|
-
const fileUploadRouteHook = ArkosRouteHook("file-upload");
|
|
6
|
-
|
|
7
|
-
fileUploadRouteHook.findFile({
|
|
8
|
-
{{#if authentication}}authentication: fileUploadPolicy.View,{{/if}}
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
fileUploadRouteHook.uploadFile({
|
|
12
|
-
{{#if authentication}}authentication: fileUploadPolicy.Create,{{/if}}
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
fileUploadRouteHook.updateFile({
|
|
16
|
-
{{#if authentication}}authentication: fileUploadPolicy.Update,{{/if}}
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
fileUploadRouteHook.deleteFile({
|
|
20
|
-
{{#if authentication}}authentication: fileUploadPolicy.Delete,{{/if}}
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
export default fileUploadRouteHook;
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { ArkosRouteHook } from 'arkos';
|
|
2
|
-
{{#if authentication}}
|
|
3
|
-
import userPolicy from '@/src/modules/user/user.policy';
|
|
4
|
-
{{/if}}
|
|
5
|
-
{{#if validation.type}}
|
|
6
|
-
import CreateUserDto from '@/src/modules/user/dtos/create-user.dto';
|
|
7
|
-
import UpdateUserDto from '@/src/modules/user/dtos/update-user.dto';
|
|
8
|
-
{{/if}}
|
|
9
|
-
|
|
10
|
-
const userRouteHook = ArkosRouteHook("user");
|
|
11
|
-
|
|
12
|
-
userRouteHook.createOne({
|
|
13
|
-
{{#if validation.type}}validation: { body: CreateUserDto },{{/if}}
|
|
14
|
-
{{#if authentication}}authentication: userPolicy.Create,{{/if}}
|
|
15
|
-
prismaArgs: {
|
|
16
|
-
omit: { password: true },
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
userRouteHook.findOne({
|
|
21
|
-
{{#if authentication}}authentication: userPolicy.View,{{/if}}
|
|
22
|
-
prismaArgs: {
|
|
23
|
-
omit: { password: true },
|
|
24
|
-
{{#if (eq authentication.type "dynamic")}}
|
|
25
|
-
include: {
|
|
26
|
-
{{#if authentication.multipleRoles}}
|
|
27
|
-
roles: {
|
|
28
|
-
include: {
|
|
29
|
-
role: {
|
|
30
|
-
include: {
|
|
31
|
-
permissions: true,
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
{{else}}
|
|
37
|
-
role: {
|
|
38
|
-
include: {
|
|
39
|
-
role: {
|
|
40
|
-
include: {
|
|
41
|
-
permissions: true,
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
{{/if}}
|
|
47
|
-
},
|
|
48
|
-
{{/if}}
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
userRouteHook.findMany({
|
|
53
|
-
{{#if authentication}}authentication: userPolicy.View,{{/if}}
|
|
54
|
-
prismaArgs: {
|
|
55
|
-
omit: { password: true },
|
|
56
|
-
{{#if (eq authentication.type "dynamic")}}
|
|
57
|
-
include: {
|
|
58
|
-
{{#if authentication.multipleRoles}}
|
|
59
|
-
roles: {
|
|
60
|
-
include: {
|
|
61
|
-
role: true,
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
{{else}}
|
|
65
|
-
role: {
|
|
66
|
-
include: {
|
|
67
|
-
role: true,
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
{{/if}}
|
|
71
|
-
},
|
|
72
|
-
{{/if}}
|
|
73
|
-
},
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
userRouteHook.updateOne({
|
|
77
|
-
{{#if validation.type}}validation: { body: UpdateUserDto },{{/if}}
|
|
78
|
-
{{#if authentication}}authentication: userPolicy.Update,{{/if}}
|
|
79
|
-
prismaArgs: {
|
|
80
|
-
omit: { password: true },
|
|
81
|
-
},
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
userRouteHook.deleteOne({
|
|
85
|
-
{{#if authentication}}authentication: userPolicy.Delete,{{/if}}
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
export default userRouteHook;
|