create-arkos 2.0.0-next.16 → 2.0.0-next.18

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.
Files changed (37) hide show
  1. package/README.md +182 -57
  2. package/dist/index.js +4 -0
  3. package/dist/index.js.map +1 -1
  4. package/dist/utils/project-config-inquirer.js +12 -4
  5. package/dist/utils/project-config-inquirer.js.map +1 -1
  6. package/dist/utils/template-compiler.js +8 -11
  7. package/dist/utils/template-compiler.js.map +1 -1
  8. package/package.json +8 -8
  9. package/templates/basic/README.md.hbs +2 -4
  10. package/templates/basic/arkos.config.ts.hbs +2 -2
  11. package/templates/basic/jsconfig.json.hbs +2 -2
  12. package/templates/basic/package.json.hbs +11 -9
  13. package/templates/basic/prisma/schema/__tests__/user-role.prisma.hbs.test.ts +1 -1
  14. package/templates/basic/prisma/schema/auth-permission.prisma.hbs +3 -9
  15. package/templates/basic/prisma/schema/auth-role.prisma.hbs +2 -2
  16. package/templates/basic/prisma/schema/user-permission.prisma.hbs +18 -0
  17. package/templates/basic/prisma/schema/user.prisma.hbs +3 -1
  18. package/templates/basic/src/app.ts.hbs +2 -4
  19. package/templates/basic/src/modules/auth/auth.policy.ts.hbs +1 -1
  20. package/templates/basic/src/modules/auth/auth.router.ts.hbs +72 -7
  21. package/templates/basic/src/modules/auth-permission/auth-permission.router.ts.hbs +39 -15
  22. package/templates/basic/src/modules/auth-permission/dtos/create-auth-permission.dto.ts.hbs +6 -9
  23. package/templates/basic/src/modules/auth-permission/dtos/update-auth-permission.dto.ts.hbs +18 -3
  24. package/templates/basic/src/modules/auth-role/auth-role.router.ts.hbs +38 -14
  25. package/templates/basic/src/modules/auth-role/dtos/create-auth-role.dto.ts.hbs +2 -7
  26. package/templates/basic/src/modules/auth-role/dtos/update-auth-role.dto.ts.hbs +2 -5
  27. package/templates/basic/src/modules/file-upload/file-upload.router.ts.hbs +28 -15
  28. package/templates/basic/src/modules/user/user.router.ts.hbs +91 -15
  29. package/templates/basic/src/router.ts.hbs +3 -6
  30. package/templates/basic/tsconfig.json.hbs +2 -2
  31. package/templates/basic/src/loadables.ts.hbs +0 -29
  32. package/templates/basic/src/modules/auth/auth.route-hook.ts.hbs +0 -66
  33. package/templates/basic/src/modules/auth-permission/auth-permission.route-hook.ts.hbs +0 -35
  34. package/templates/basic/src/modules/auth-role/auth-role.route-hook.ts.hbs +0 -35
  35. package/templates/basic/src/modules/file-upload/file-upload.route-hook.ts.hbs +0 -23
  36. package/templates/basic/src/modules/user/user.route-hook.ts.hbs +0 -88
  37. /package/templates/basic/src/modules/auth-permission/dtos/{query-auth-role.dto.ts.hbs → query-auth-permission.dto.ts.hbs} +0 -0
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "create-arkos",
3
- "version": "2.0.0-next.16",
3
+ "version": "2.0.0-next.18",
4
4
  "type": "module",
5
5
  "description": "CLI for creating Arkos.js projects, see docs at www.arkosjs.com",
6
6
  "bin": {
7
- "create-arkos": "dist/index.js"
7
+ "create-arkos": "./dist/index.js"
8
8
  },
9
9
  "scripts": {
10
10
  "test": "vitest --coverage",
@@ -26,23 +26,23 @@
26
26
  "bugs": {
27
27
  "url": "https://github.com/uanela/arkos/issues"
28
28
  },
29
- "homepage": "https://www.arkosjs.com/docs/cli/create-arkos",
29
+ "homepage": "https://www.arkosjs.com/docs/tooling/cli/overviewcreate-arkos",
30
30
  "files": ["dist", "templates", "cli.js", "README.md"],
31
31
  "devDependencies": {
32
- "@types/inquirer": "9.0.9",
32
+ "@types/inquirer": "8.1.0",
33
33
  "@types/node": "16.18.126",
34
- "@vitest/coverage-v8": "4.1.7",
34
+ "@vitest/coverage-v8": "3.2.4",
35
35
  "rimraf": "6.1.3",
36
36
  "ts-node": "10.9.2",
37
37
  "tsx": "4.21.0",
38
38
  "typescript": "4.9.5",
39
- "vitest": "4.1.7"
39
+ "vitest": "3.2.4"
40
40
  },
41
41
  "dependencies": {
42
42
  "@clack/prompts": "0.11.0",
43
- "@inquirer/prompts": "7",
43
+ "@inquirer/prompts": "7.6.0",
44
44
  "chalk": "5.4.1",
45
- "handlebars": "^4.7.9",
45
+ "handlebars": "4.7.8",
46
46
  "inquirer": "8.2.6"
47
47
  }
48
48
  }
@@ -1,13 +1,11 @@
1
- This is a [Arkos.js](https://arkosjs.com) project scaffolded with [`create-arkos`](https://arkosjs.com/docs/tooling/cli/overviewcreate-arkos).
1
+ This is an [Arkos.js](https://arkosjs.com) project scaffolded with [`create-arkos`](https://arkosjs.com/docs/tooling/create-arkos).
2
2
 
3
3
  ## Getting Started
4
4
 
5
5
  First, run the development server:
6
6
 
7
7
  ```bash
8
- pnpm dev
9
- # or
10
- npm run dev
8
+ {{packageManager}} run dev
11
9
  ```
12
10
 
13
11
  - Visit [http://localhost:8000/api/docs](http://localhost:8000/api/docs) with your browser to see the swagger api documentation.
@@ -1,5 +1,5 @@
1
1
  import { defineConfig } from "arkos/config"
2
- import prisma from "./src/utils/prisma"
2
+ import prisma from "@/src/utils/prisma"
3
3
 
4
4
  const arkosConfig = defineConfig({
5
5
  globalPrefix: "/api",
@@ -45,7 +45,7 @@ const arkosConfig = defineConfig({
45
45
  noSchemaFound: true,
46
46
  },
47
47
  },
48
- },
48
+ }
49
49
  {{/if}}
50
50
  })
51
51
 
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "target": "es2022",
4
- "module": "es2022",
3
+ "target": "ES6",
4
+ "module": "es2020",
5
5
  "moduleResolution": "bundler",
6
6
  "rootDir": ".",
7
7
  "baseUrl": ".",
@@ -1,5 +1,7 @@
1
1
  {
2
2
  "name": "{{projectName}}",
3
+ "version": "1.0.0",
4
+ "type": "module",
3
5
  "description": "This RESTful API was generated by create-arkos, read more about Arkos.js at www.arkosjs.com",
4
6
  "scripts": {
5
7
  "dev": "arkos dev",
@@ -16,18 +18,18 @@
16
18
  "@types/node": "24.0.12",
17
19
  "@types/express": "5.0.0",
18
20
  {{/if}}
19
- "tsx-strict": "0.7.0",
20
- "tsx": "4.21.0"{{#if (neq prisma.provider "none")}},
21
- "prisma": "6.19.2"
21
+ "tsx-strict": "0.8.0",
22
+ "tsx": "4.23.1"{{#if (neq prisma.provider "none")}},
23
+ "prisma": "6.19.3"
22
24
  {{/if}}
23
25
  },
24
26
  "dependencies": {
25
- "arkos": "2.0.0-next.16",
26
- "express": "4.22.1",
27
- "@scalar/express-api-reference": "0.8.35",
28
- "@scalar/api-reference": "1.55.3",
27
+ "arkos": "2.0.0-next.18",
28
+ "express": "4.22.2",
29
+ "@scalar/express-api-reference": "0.10.2",
30
+ "@scalar/api-reference": "1.55.3"{{#if (or (neq prisma.provider "none") validation.type)}},{{/if}}
29
31
  {{#if (neq prisma.provider "none")}}
30
- "@prisma/client": "6.19.2"{{#if validation.type}},{{/if}}
32
+ "@prisma/client": "6.19.3"{{#if validation.type}},{{/if}}
31
33
  {{/if}}
32
34
  {{#if (eq validation.type "class-validator")}}
33
35
  "reflect-metadata": "0.2.2",
@@ -35,7 +37,7 @@
35
37
  "class-validator": "0.14.1"
36
38
  {{/if}}
37
39
  {{#if (eq validation.type "zod")}}
38
- "zod": "3.24.2"
40
+ "zod": "3.25.76"
39
41
  {{/if}}
40
42
  }
41
43
  }
@@ -24,7 +24,7 @@ describe("UserRole model template rendering", () => {
24
24
  const result1 = renderTemplate(templatePath, context1);
25
25
  expect(result1.trim()).toBe("");
26
26
 
27
- // Test case 2: Define later authentication
27
+ // Test case 2: none authentication
28
28
  const context2 = {
29
29
  authentication: {
30
30
  type: "none",
@@ -1,17 +1,11 @@
1
1
  model AuthPermission {
2
2
  id String {{{prisma.idDatabaseType}}}
3
3
  resource String
4
- {{#if (eq prisma.provider "sqlite")}}
5
4
  action String @default("View")
6
- {{else}}
7
- action String @default("View")
8
- {{/if}}
9
- roleId String {{#if (eq prisma.provider "mongodb")}}@db.ObjectId{{/if}}
10
- role AuthRole @relation(fields: [roleId], references: [id])
5
+ roles AuthRole[]
6
+ users UserPermission[]
11
7
  createdAt DateTime @default(now())
12
8
  updatedAt DateTime @updatedAt
13
9
 
14
- @@unique([resource, action, roleId])
10
+ @@unique([resource, action])
15
11
  }
16
-
17
-
@@ -4,7 +4,7 @@ model AuthRole {
4
4
  description String?
5
5
  permissions AuthPermission[]
6
6
  users UserRole[]
7
- createdAt DateTime @default(now())
8
- updatedAt DateTime @updatedAt
7
+ createdAt DateTime @default(now())
8
+ updatedAt DateTime @updatedAt
9
9
  }
10
10
 
@@ -0,0 +1,18 @@
1
+ model UserPermission {
2
+ id String @id @default(uuid())
3
+ createdAt DateTime @default(now())
4
+ updatedAt DateTime @updatedAt
5
+
6
+ effect UserPermissionEffect @default(Allow)
7
+ userId String
8
+ user User @relation(fields: [userId], references: [id])
9
+ permissionId String
10
+ permission AuthPermission @relation(fields: [permissionId], references: [id])
11
+
12
+ @@unique([userId, permissionId])
13
+ }
14
+
15
+ enum UserPermissionEffect {
16
+ Allow
17
+ Deny
18
+ }
@@ -30,9 +30,11 @@ model User {
30
30
  {{/if}}
31
31
  {{/if}}
32
32
  {{/if}}
33
+ {{#if (eq authentication.type "dynamic")}}
34
+ permissions UserPermission[]
35
+ {{/if}}
33
36
  createdAt DateTime @default(now())
34
37
  updatedAt DateTime @updatedAt
35
- // other fields for your application
36
38
  }
37
39
 
38
40
  {{#if (eq authentication.type "static")}}
@@ -1,12 +1,9 @@
1
1
  import arkos from "arkos";
2
- import router from "@/src/router"
3
- import loadables from "@/src/loadables"
2
+ import router from "@/src/router";
4
3
 
5
4
  const app = arkos();
6
5
 
7
6
  app.set("trust proxy", 1);
8
-
9
- app.load(loadables)
10
7
  app.use(router);
11
8
 
12
9
  {{#if (eq entryPoint "src/app")}}
@@ -14,3 +11,4 @@ app.listen();
14
11
  {{else}}
15
12
  export default app;
16
13
  {{/if}}
14
+
@@ -1,5 +1,5 @@
1
1
  import { ArkosPolicy } from "arkos";
2
2
 
3
- const authPolicy = ArkosPolicy("auth-permission")
3
+ const authPolicy = ArkosPolicy("auth")
4
4
 
5
5
  export default authPolicy;
@@ -1,11 +1,76 @@
1
- import { ArkosRouter } from "arkos";
2
- {{#if authentication}}
3
- import authPolicy from "@/src/modules/auth/auth.policy";
1
+ import { ArkosRouter, ArkosRouteHook } from 'arkos';
2
+ {{#if (neq authentication.type "none")}}
3
+ import authPolicy from '@/src/modules/auth/auth.policy';
4
4
  {{/if}}
5
+ {{#if validation.type}}
6
+ import LoginDto from '@/src/modules/auth/dtos/login.dto';
7
+ import SignupDto from '@/src/modules/auth/dtos/signup.dto';
8
+ import UpdateMeDto from '@/src/modules/auth/dtos/update-me.dto';
9
+ import UpdatePasswordDto from '@/src/modules/auth/dtos/update-password.dto';
10
+ {{/if}}
11
+
12
+ const authRouteHook = ArkosRouteHook("auth");
13
+
14
+ authRouteHook.login({
15
+ {{#if validation.type}}validation: { body: LoginDto },{{/if}}
16
+ });
17
+
18
+ authRouteHook.signup({
19
+ {{#if validation.type}}validation: { body: SignupDto },{{/if}}
20
+ prismaArgs: {
21
+ omit: { password: true },
22
+ },
23
+ });
24
+
25
+ authRouteHook.getMe({
26
+ prismaArgs: {
27
+ omit: { password: true },
28
+ {{#if (eq authentication.type "dynamic")}}
29
+ include: {
30
+ {{#if authentication.multipleRoles}}
31
+ roles: {
32
+ include: {
33
+ role: {
34
+ include: {
35
+ permissions: true,
36
+ },
37
+ },
38
+ },
39
+ },
40
+ {{else}}
41
+ role: {
42
+ include: {
43
+ role: {
44
+ include: {
45
+ permissions: true,
46
+ },
47
+ },
48
+ },
49
+ },
50
+ {{/if}}
51
+ },
52
+ {{/if}}
53
+ },
54
+ });
55
+
56
+ authRouteHook.updateMe({
57
+ {{#if validation.type}}validation: { body: UpdateMeDto },{{/if}}
58
+ prismaArgs: {
59
+ omit: { password: true },
60
+ },
61
+ });
62
+
63
+ authRouteHook.updatePassword({
64
+ {{#if validation.type}}validation: { body: UpdatePasswordDto },{{/if}}
65
+ });
66
+
67
+ authRouteHook.logout({});
68
+
69
+ const authRouter = ArkosRouter({
70
+ prefix: "/auth",
71
+ openapi: { tags: ["Authentication"] },
72
+ });
5
73
 
6
- const authRouter = ArkosRouter({
7
- prefix: "/auth",
8
- openapi: { tags: ["Authentication"] }
9
- });
74
+ authRouter.load(authRouteHook);
10
75
 
11
76
  export default authRouter;
@@ -1,19 +1,43 @@
1
- import { ArkosRouter{{#if typescript}}, RouteHook{{/if}} } from "arkos";
2
- {{#if authentication}}
3
- import authPermissionPolicy from "@/src/modules/auth-permission/auth-permission.policy";
4
-
5
- export const hook{{#if typescript}}: RouteHook{{/if}} = {
6
- createOne: { authentication: authPermissionPolicy.Create },
7
- findMany: { authentication: authPermissionPolicy.View },
8
- findOne: { authentication: authPermissionPolicy.View },
9
- updateOne: { authentication: authPermissionPolicy.Update },
10
- deleteOne: { authentication: authPermissionPolicy.Delete },
11
- };
1
+ import { ArkosRouter, ArkosRouteHook } from 'arkos';
2
+ {{#if (neq authentication.type "none")}}
3
+ import authPermissionPolicy from '@/src/modules/auth-permission/auth-permission.policy';
12
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
+
11
+ const authPermissionRouteHook = ArkosRouteHook("auth-permission");
12
+
13
+ authPermissionRouteHook.createOne({
14
+ {{#if validation.type}}validation: { body: CreateAuthPermissionDto },{{/if}}
15
+ {{#if (neq authentication.type "none")}}authentication: authPermissionPolicy.Create,{{/if}}
16
+ });
17
+
18
+ authPermissionRouteHook.findOne({
19
+ {{#if (neq authentication.type "none")}}authentication: authPermissionPolicy.View,{{/if}}
20
+ });
21
+
22
+ authPermissionRouteHook.findMany({
23
+ {{#if validation.type}}validation: { query: QueryAuthPermissionDto },{{/if}}
24
+ {{#if (neq authentication.type "none")}}authentication: authPermissionPolicy.View,{{/if}}
25
+ });
26
+
27
+ authPermissionRouteHook.updateOne({
28
+ {{#if validation.type}}validation: { body: UpdateAuthPermissionDto },{{/if}}
29
+ {{#if (neq authentication.type "none")}}authentication: authPermissionPolicy.Update,{{/if}}
30
+ });
31
+
32
+ authPermissionRouteHook.deleteOne({
33
+ {{#if (neq authentication.type "none")}}authentication: authPermissionPolicy.Delete,{{/if}}
34
+ });
35
+
36
+ const authPermissionRouter = ArkosRouter({
37
+ prefix: "/auth-permissions",
38
+ openapi: { tags: ["Auth Permissions"] },
39
+ });
13
40
 
14
- const authPermissionRouter = ArkosRouter({
15
- prefix: "/auth-permissions",
16
- openapi: { tags: ["Auth Permissions"] }
17
- });
41
+ authPermissionRouter.load(authPermissionRouteHook);
18
42
 
19
43
  export default authPermissionRouter;
@@ -4,9 +4,9 @@ import { z } from 'zod';
4
4
  const CreateAuthPermissionDto = z.object({
5
5
  resource: z.string().min(1, 'Resource is required'),
6
6
  action: z.string().default('View'),
7
- role: z.object({
7
+ roles: z.array(z.object({
8
8
  id: z.string().min(1, 'Role ID is required'),
9
- }),
9
+ })).optional(),
10
10
  description: z.string().optional(),
11
11
  });
12
12
 
@@ -16,7 +16,7 @@ export type CreateAuthPermissionDtoType = z.infer<typeof CreateAuthPermissionDto
16
16
  {{/if}}
17
17
  {{/if}}
18
18
  {{#if (eq validation.type "class-validator")}}
19
- import { IsString, IsNotEmpty, IsOptional, IsValidateNested } from 'class-validator';
19
+ import { IsString, IsNotEmpty, IsOptional, IsArray, ValidateNested } from 'class-validator';
20
20
  import { Type, Transform } from 'class-transformer';
21
21
  import 'reflect-metadata';
22
22
 
@@ -35,13 +35,10 @@ export default class CreateAuthPermissionDto {
35
35
  @Transform(({ value }) => value || 'View')
36
36
  action?: string = 'View';
37
37
 
38
- @ValidateNested()
38
+ @ValidateNested({ each: true })
39
+ @IsArray()
39
40
  @Type(() => RoleConnectDto)
40
- role!: RoleConnectDto;
41
-
42
41
  @IsOptional()
43
- @IsString()
44
- @Transform(({ value }) => value)
45
- description?: string;
42
+ roles?: RoleConnectDto[];
46
43
  }
47
44
  {{/if}}
@@ -5,6 +5,9 @@ const UpdateAuthPermissionDto = z.object({
5
5
  resource: z.string().optional(),
6
6
  action: z.string().optional(),
7
7
  description: z.string().optional(),
8
+ roles: z.array(z.object({
9
+ id: z.string().min(1, 'Role ID is required'),
10
+ })).optional(),
8
11
  });
9
12
 
10
13
  export default UpdateAuthPermissionDto;
@@ -13,10 +16,16 @@ export type UpdateAuthPermissionDtoType = z.infer<typeof UpdateAuthPermissionDto
13
16
  {{/if}}
14
17
  {{/if}}
15
18
  {{#if (eq validation.type "class-validator")}}
16
- import { IsString, IsOptional } from 'class-validator';
17
- import { Transform } from 'class-transformer';
19
+ import { IsString, IsOptional, IsArray, ValidateNested } from 'class-validator';
20
+ import { Transform, Type } from 'class-transformer';
18
21
  import 'reflect-metadata';
19
22
 
23
+ class RoleConnectDto {
24
+ @IsString()
25
+ @IsNotEmpty({ message: 'Role ID is required' })
26
+ id!: string;
27
+ }
28
+
20
29
  export default class UpdateAuthPermissionDto {
21
30
  @IsOptional()
22
31
  @IsString()
@@ -24,11 +33,17 @@ export default class UpdateAuthPermissionDto {
24
33
 
25
34
  @IsOptional()
26
35
  @IsString()
27
- @Transform(({ value }) => value)
36
+ @Transform(({ value }) => String(value))
28
37
  action?: string;
29
38
 
30
39
  @IsOptional()
31
40
  @IsString()
32
41
  description?: string;
42
+
43
+ @ValidateNested({ each: true })
44
+ @IsArray()
45
+ @Type(() => RoleConnectDto)
46
+ @IsOptional()
47
+ roles?: RoleConnectDto[];
33
48
  }
34
49
  {{/if}}
@@ -1,19 +1,43 @@
1
- import { ArkosRouter{{#if typescript}}, RouteHook{{/if}} } from "arkos";
2
- {{#if authentication}}
3
- import authRolePolicy from "@/src/modules/auth-role/auth-role.policy";
4
-
5
- export const hook{{#if typescript}}: RouteHook{{/if}} = {
6
- createOne: { authentication: authRolePolicy.Create },
7
- findMany: { authentication: authRolePolicy.View },
8
- findOne: { authentication: authRolePolicy.View },
9
- updateOne: { authentication: authRolePolicy.Update },
10
- deleteOne: { authentication: authRolePolicy.Delete },
11
- };
1
+ import { ArkosRouter, ArkosRouteHook } from 'arkos';
2
+ {{#if (neq authentication.type "none")}}
3
+ import authRolePolicy from '@/src/modules/auth-role/auth-role.policy';
12
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
+
11
+ const authRoleRouteHook = ArkosRouteHook("auth-role");
12
+
13
+ authRoleRouteHook.createOne({
14
+ {{#if validation.type}}validation: { body: CreateAuthRoleDto },{{/if}}
15
+ {{#if (neq authentication.type "none")}}authentication: authRolePolicy.Create,{{/if}}
16
+ });
17
+
18
+ authRoleRouteHook.findOne({
19
+ {{#if (neq authentication.type "none")}}authentication: authRolePolicy.View,{{/if}}
20
+ });
21
+
22
+ authRoleRouteHook.findMany({
23
+ {{#if validation.type}}validation: { query: QueryAuthRoleDto },{{/if}}
24
+ {{#if (neq authentication.type "none")}}authentication: authRolePolicy.View,{{/if}}
25
+ });
26
+
27
+ authRoleRouteHook.updateOne({
28
+ {{#if validation.type}}validation: { body: UpdateAuthRoleDto },{{/if}}
29
+ {{#if (neq authentication.type "none")}}authentication: authRolePolicy.Update,{{/if}}
30
+ });
31
+
32
+ authRoleRouteHook.deleteOne({
33
+ {{#if (neq authentication.type "none")}}authentication: authRolePolicy.Delete,{{/if}}
34
+ });
13
35
 
14
36
  const authRoleRouter = ArkosRouter({
15
- prefix: "/auth-roles",
16
- openapi: { tags: ["Auth Roles"] }
17
- });
37
+ prefix: "/auth-roles",
38
+ openapi: { tags: ["Auth Roles"] },
39
+ });
40
+
41
+ authRoleRouter.load(authRoleRouteHook);
18
42
 
19
43
  export default authRoleRouter;
@@ -29,13 +29,8 @@ class CreatePermissionForRoleDto {
29
29
  resource!: string;
30
30
 
31
31
  @IsString()
32
- @Transform(({ value }) => value || 'View')
33
- action: string = 'View';
34
-
35
- @IsOptional()
36
- @IsString()
37
- @Transform(({ value }) => value)
38
- description?: string;
32
+ @Transform(({ value }) => String(value))
33
+ action!: string;
39
34
  }
40
35
 
41
36
  export default class CreateAuthRoleDto {
@@ -27,6 +27,7 @@ import 'reflect-metadata';
27
27
 
28
28
  export enum ApiAction {
29
29
  connect = 'connect',
30
+ disconnect = 'disconnect',
30
31
  delete = 'delete',
31
32
  create = 'create',
32
33
  update = 'update'
@@ -45,11 +46,7 @@ class UpdatePermissionForRoleDto {
45
46
  @IsNotEmpty()
46
47
  action!: string;
47
48
 
48
- @IsOptional()
49
- @IsString()
50
- @Transform(({ value }) => value)
51
- description?: string;
52
-
49
+ @IsEnum(ApiAction)
53
50
  @IsOptional()
54
51
  @IsString()
55
52
  apiAction?: ApiAction;
@@ -1,19 +1,32 @@
1
- import { ArkosRouter{{#if typescript}}, RouteHook{{/if}} } from "arkos";
2
- import config from "@/arkos.config"
3
- {{#if authentication}}
4
- import fileUploadPolicy from "@/src/modules/file-upload/file-upload.policy";
5
-
6
- export const hook{{#if typescript}}: RouteHook<"file-upload">{{/if}} = {
7
- findFile: { authentication: fileUploadPolicy.View },
8
- uploadFile: { authentication: fileUploadPolicy.Create },
9
- updateFile: { authentication: fileUploadPolicy.Update },
10
- deleteFile: { authentication: fileUploadPolicy.Delete },
11
- };
1
+ import { ArkosRouter, ArkosRouteHook } from 'arkos';
2
+ {{#if (neq authentication.type "none")}}
3
+ import fileUploadPolicy from '@/src/modules/file-upload/file-upload.policy';
12
4
  {{/if}}
5
+ import config from '@/arkos.config';
13
6
 
14
- const fileUploadRouter = ArkosRouter({
15
- prefix: config?.fileUpload?.baseRoute,
16
- openapi: { tags: ["File Uploads"] }
17
- });
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 Uploads"] },
28
+ });
29
+
30
+ fileUploadRouter.load(fileUploadRouteHook);
18
31
 
19
32
  export default fileUploadRouter;