create-nexwire 4.0.0 → 4.1.0
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 +5 -4
- package/express/.env +1 -1
- package/express/README.md +13 -7
- package/express/package.json +2 -2
- package/express/src/config/session.ts +1 -1
- package/express/src/database/migrations/sqlite/meta/0000_snapshot.json +1 -1
- package/express/src/database/migrations/sqlite/meta/_journal.json +1 -1
- package/express/src/database/schema.ts +3 -3
- package/express/src/framework/cache/cache.ts +82 -81
- package/express/src/framework/database/seed.ts +1 -1
- package/express/src/framework/facade.ts +1 -24
- package/express/src/framework/http/app.ts +5 -5
- package/express/src/framework/http/openapi.ts +1 -1
- package/express/src/framework/http/router.ts +3 -18
- package/express/src/framework/http/types.ts +19 -0
- package/express/src/framework/http/validation.ts +18 -18
- package/express/src/framework/maker-cli/middleware/core.mjs +41 -47
- package/express/src/framework/maker-cli/module/core.mjs +920 -684
- package/express/src/framework/maker-cli/module/index.mjs +202 -140
- package/express/src/framework/maker-cli/runtime/core.mjs +1 -2
- package/express/src/framework/maker-cli/stubs/controller/openapi.ts.stub +40 -14
- package/express/src/framework/maker-cli/stubs/controller/openapi.with-model.ts.stub +40 -15
- package/express/src/framework/maker-cli/stubs/controller/plain.ts.stub +42 -16
- package/express/src/framework/maker-cli/stubs/controller/standalone.ts.stub +47 -0
- package/express/src/framework/maker-cli/stubs/facade/name.ts.stub +12 -0
- package/express/src/framework/maker-cli/stubs/helper/name.ts.stub +14 -0
- package/express/src/framework/maker-cli/stubs/middleware/name.local.ts.stub +15 -0
- package/express/src/framework/maker-cli/stubs/model/name.mysql.ts.stub +9 -8
- package/express/src/framework/maker-cli/stubs/model/name.postgresql.ts.stub +9 -8
- package/express/src/framework/maker-cli/stubs/model/name.sqlite.ts.stub +9 -8
- package/express/src/framework/maker-cli/stubs/notification/route.api.ts.stub +50 -50
- package/express/src/framework/maker-cli/stubs/notification/route.plain.ts.stub +11 -11
- package/express/src/framework/maker-cli/stubs/route/api.ts.stub +93 -79
- package/express/src/framework/maker-cli/stubs/route/plain.ts.stub +23 -10
- package/express/src/framework/maker-cli/stubs/route/standalone.api.ts.stub +113 -0
- package/express/src/framework/maker-cli/stubs/route/standalone.plain.ts.stub +37 -0
- package/express/src/framework/maker-cli/stubs/{controller/schema.plain.ts.stub → schema/name.plain.ts.stub} +13 -13
- package/express/src/framework/maker-cli/stubs/{controller/schema.ts.stub → schema/name.ts.stub} +32 -32
- package/express/src/framework/maker-cli/stubs/service/name.plain.ts.stub +67 -0
- package/express/src/framework/maker-cli/stubs/service/name.ts.stub +65 -0
- package/express/src/framework/maker-cli/stubs/type/name.ts.stub +22 -0
- package/express/src/framework/maker-cli/utils/naming.mjs +56 -13
- package/express/src/framework/modules/discover.ts +57 -54
- package/express/src/framework/notification/index.ts +1 -1
- package/express/src/framework/realtime/broadcast.ts +46 -46
- package/express/src/framework/server.ts +2 -1
- package/express/src/framework/session/session.ts +102 -98
- package/express/src/framework/support/mail.ts +48 -48
- package/express/src/framework/support/status-codes.ts +75 -0
- package/express/src/middlewares/auth-middleware.ts +1 -1
- package/express/src/modules/auth/__tests__/forgetpass.test.ts +200 -0
- package/express/src/modules/auth/__tests__/login.test.ts +171 -0
- package/express/src/modules/auth/__tests__/logout.test.ts +60 -0
- package/express/src/modules/auth/__tests__/logoutalldevices.test.ts +49 -0
- package/express/src/modules/auth/__tests__/me.test.ts +91 -0
- package/express/src/modules/auth/__tests__/refreshtoken.test.ts +305 -0
- package/express/src/modules/auth/__tests__/register.test.ts +291 -0
- package/express/src/modules/auth/__tests__/resetpass.test.ts +206 -0
- package/express/src/modules/auth/__tests__/verifyemail.test.ts +183 -0
- package/express/src/modules/auth/controllers/auth.ts +254 -0
- package/express/src/modules/auth/controllers/{role.controller.ts → role.ts} +25 -15
- package/{hono/src/modules/auth/database/models/notifications.ts → express/src/modules/auth/database/models/notification.ts} +1 -1
- package/express/src/modules/auth/database/models/role.ts +1 -1
- package/express/src/modules/auth/database/models/user.ts +1 -1
- package/express/src/modules/auth/facade.ts +12 -0
- package/express/src/modules/auth/{controllers/auth.helpers.ts → helpers/auth.ts} +3 -4
- package/express/src/modules/auth/jobs/registeruser.ts +23 -23
- package/express/src/modules/auth/routes/{api.ts → index.ts} +150 -150
- package/express/src/modules/auth/routes/role.ts +33 -33
- package/{hono/src/modules/auth/controllers/auth.schema.ts → express/src/modules/auth/schemas/auth.ts} +102 -102
- package/express/src/modules/auth/services/forgetpassword.ts +66 -0
- package/express/src/modules/auth/services/login.ts +63 -0
- package/express/src/modules/auth/services/logout.ts +25 -0
- package/express/src/modules/auth/services/logoutalldevices.ts +19 -0
- package/express/src/modules/auth/services/me.ts +31 -0
- package/express/src/modules/auth/services/refreshtoken.ts +110 -0
- package/express/src/modules/auth/services/register.ts +141 -0
- package/express/src/modules/auth/services/resetpassword.ts +69 -0
- package/express/src/modules/auth/services/verifyemail.ts +77 -0
- package/express/src/modules/auth/types/auth.ts +31 -0
- package/express/src/resources/src/assets/images/logo.png +0 -0
- package/express/src/resources/src/pages/auth/forgetPassword.vue +1 -0
- package/express/src/resources/src/pages/auth/login.vue +1 -1
- package/express/src/storage/database/nexwire.sqlite +0 -0
- package/hono/.env +1 -1
- package/hono/README.md +13 -7
- package/hono/package.json +1 -1
- package/hono/src/config/session.ts +1 -1
- package/hono/src/database/migrations/sqlite/meta/0000_snapshot.json +1 -1
- package/hono/src/database/migrations/sqlite/meta/_journal.json +1 -1
- package/hono/src/database/schema.ts +3 -3
- package/hono/src/framework/cache/cache.ts +82 -81
- package/hono/src/framework/database/seed.ts +1 -1
- package/hono/src/framework/http/app.ts +5 -5
- package/hono/src/framework/http/validation.ts +21 -21
- package/hono/src/framework/maker-cli/middleware/core.mjs +40 -46
- package/hono/src/framework/maker-cli/module/core.mjs +401 -168
- package/hono/src/framework/maker-cli/module/index.mjs +73 -11
- package/hono/src/framework/maker-cli/stubs/controller/openapi.ts.stub +28 -16
- package/hono/src/framework/maker-cli/stubs/controller/openapi.with-model.ts.stub +28 -17
- package/hono/src/framework/maker-cli/stubs/controller/plain.ts.stub +28 -16
- package/hono/src/framework/maker-cli/stubs/controller/standalone.ts.stub +56 -0
- package/hono/src/framework/maker-cli/stubs/facade/name.ts.stub +12 -0
- package/hono/src/framework/maker-cli/stubs/helper/name.ts.stub +14 -0
- package/hono/src/framework/maker-cli/stubs/middleware/name.local.ts.stub +15 -0
- package/hono/src/framework/maker-cli/stubs/model/name.mysql.ts.stub +9 -8
- package/hono/src/framework/maker-cli/stubs/model/name.postgresql.ts.stub +9 -8
- package/hono/src/framework/maker-cli/stubs/model/name.sqlite.ts.stub +9 -8
- package/hono/src/framework/maker-cli/stubs/notification/route.api.ts.stub +49 -49
- package/hono/src/framework/maker-cli/stubs/notification/route.plain.ts.stub +11 -11
- package/hono/src/framework/maker-cli/stubs/route/api.ts.stub +93 -79
- package/hono/src/framework/maker-cli/stubs/route/plain.ts.stub +23 -10
- package/hono/src/framework/maker-cli/stubs/route/standalone.api.ts.stub +112 -0
- package/hono/src/framework/maker-cli/stubs/route/standalone.plain.ts.stub +37 -0
- package/hono/src/framework/maker-cli/stubs/{controller/schema.plain.ts.stub → schema/name.plain.ts.stub} +13 -13
- package/hono/src/framework/maker-cli/stubs/{controller/schema.ts.stub → schema/name.ts.stub} +32 -32
- package/hono/src/framework/maker-cli/stubs/service/name.plain.ts.stub +67 -0
- package/hono/src/framework/maker-cli/stubs/service/name.ts.stub +65 -0
- package/hono/src/framework/maker-cli/stubs/type/name.ts.stub +22 -0
- package/hono/src/framework/maker-cli/utils/naming.mjs +56 -13
- package/hono/src/framework/modules/discover.ts +57 -54
- package/hono/src/framework/notification/index.ts +1 -1
- package/hono/src/framework/realtime/broadcast.ts +46 -46
- package/hono/src/framework/server.ts +1 -1
- package/hono/src/framework/session/session.ts +121 -116
- package/hono/src/middlewares/auth-middleware.ts +1 -1
- package/hono/src/modules/auth/__tests__/forgetpass.test.ts +170 -0
- package/hono/src/modules/auth/__tests__/login.test.ts +154 -0
- package/hono/src/modules/auth/__tests__/logout.test.ts +53 -0
- package/hono/src/modules/auth/__tests__/logoutalldevices.test.ts +34 -0
- package/hono/src/modules/auth/__tests__/me.test.ts +87 -0
- package/hono/src/modules/auth/__tests__/refreshtoken.test.ts +305 -0
- package/hono/src/modules/auth/__tests__/register.test.ts +258 -0
- package/hono/src/modules/auth/__tests__/resetpass.test.ts +214 -0
- package/hono/src/modules/auth/__tests__/verifyemail.test.ts +189 -0
- package/hono/src/modules/auth/controllers/auth.ts +238 -0
- package/hono/src/modules/auth/controllers/{role.controller.ts → role.ts} +25 -25
- package/{express/src/modules/auth/database/models/notifications.ts → hono/src/modules/auth/database/models/notification.ts} +1 -1
- package/hono/src/modules/auth/database/models/role.ts +1 -1
- package/hono/src/modules/auth/database/models/user.ts +1 -1
- package/hono/src/modules/auth/facade.ts +12 -0
- package/hono/src/modules/auth/{controllers/auth.helpers.ts → helpers/auth.ts} +5 -6
- package/hono/src/modules/auth/jobs/registeruser.ts +23 -23
- package/hono/src/modules/auth/routes/{api.ts → index.ts} +150 -150
- package/hono/src/modules/auth/routes/role.ts +33 -33
- package/{express/src/modules/auth/controllers/auth.schema.ts → hono/src/modules/auth/schemas/auth.ts} +102 -102
- package/hono/src/modules/auth/services/forgetpassword.ts +58 -0
- package/hono/src/modules/auth/services/login.ts +61 -0
- package/hono/src/modules/auth/services/logout.ts +24 -0
- package/hono/src/modules/auth/services/logoutalldevices.ts +19 -0
- package/hono/src/modules/auth/services/me.ts +31 -0
- package/hono/src/modules/auth/services/refreshtoken.ts +110 -0
- package/hono/src/modules/auth/services/register.ts +132 -0
- package/hono/src/modules/auth/services/resetpassword.ts +69 -0
- package/hono/src/modules/auth/services/verifyemail.ts +77 -0
- package/hono/src/modules/auth/types/auth.ts +31 -0
- package/hono/src/resources/src/assets/images/logo.png +0 -0
- package/hono/src/storage/database/nexwire.sqlite +0 -0
- package/package.json +1 -1
- package/express/src/framework/maker-cli/stubs/example/console.ts.stub +0 -34
- package/express/src/framework/maker-cli/stubs/example/controller.ts.stub +0 -418
- package/express/src/framework/maker-cli/stubs/example/job.ts.stub +0 -75
- package/express/src/framework/maker-cli/stubs/example/route.api.ts.stub +0 -207
- package/express/src/framework/maker-cli/stubs/example/route.plain.ts.stub +0 -18
- package/express/src/framework/maker-cli/stubs/example/schema.plain.ts.stub +0 -42
- package/express/src/framework/maker-cli/stubs/example/schema.ts.stub +0 -42
- package/express/src/modules/auth/controllers/auth.controller.ts +0 -358
- package/hono/src/framework/maker-cli/stubs/example/console.ts.stub +0 -34
- package/hono/src/framework/maker-cli/stubs/example/controller.ts.stub +0 -505
- package/hono/src/framework/maker-cli/stubs/example/job.ts.stub +0 -75
- package/hono/src/framework/maker-cli/stubs/example/route.api.ts.stub +0 -207
- package/hono/src/framework/maker-cli/stubs/example/route.plain.ts.stub +0 -18
- package/hono/src/framework/maker-cli/stubs/example/schema.plain.ts.stub +0 -42
- package/hono/src/framework/maker-cli/stubs/example/schema.ts.stub +0 -42
- package/hono/src/modules/auth/controllers/auth.controller.ts +0 -413
|
@@ -1,140 +1,202 @@
|
|
|
1
|
-
import { runSeed } from "../db/core.mjs";
|
|
2
|
-
import { assertName } from "../utils/naming.mjs";
|
|
3
|
-
import {
|
|
4
|
-
assertModuleHasSeeders,
|
|
5
|
-
cleanModuleTrash,
|
|
6
|
-
deleteModule,
|
|
7
|
-
deleteNotificationModule,
|
|
8
|
-
listModules,
|
|
9
|
-
makeController,
|
|
10
|
-
|
|
11
|
-
makeJob,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
program
|
|
30
|
-
.command("module:make
|
|
31
|
-
.description("
|
|
32
|
-
.
|
|
33
|
-
.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
.
|
|
41
|
-
.
|
|
42
|
-
|
|
43
|
-
.
|
|
44
|
-
.
|
|
45
|
-
.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
.
|
|
55
|
-
.
|
|
56
|
-
.
|
|
57
|
-
.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
.
|
|
64
|
-
.
|
|
65
|
-
.
|
|
66
|
-
.
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
.
|
|
73
|
-
.
|
|
74
|
-
.option("--
|
|
75
|
-
.option("--
|
|
76
|
-
.allowUnknownOption(true)
|
|
77
|
-
.action(async (
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
.
|
|
84
|
-
.
|
|
85
|
-
|
|
86
|
-
.
|
|
87
|
-
.
|
|
88
|
-
.
|
|
89
|
-
.
|
|
90
|
-
|
|
91
|
-
.
|
|
92
|
-
|
|
93
|
-
.
|
|
94
|
-
.
|
|
95
|
-
.option("--
|
|
96
|
-
.
|
|
97
|
-
.
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
.
|
|
101
|
-
.
|
|
102
|
-
.option("--
|
|
103
|
-
.option("--
|
|
104
|
-
.allowUnknownOption(true)
|
|
105
|
-
.action(async (moduleName, name) =>
|
|
106
|
-
program
|
|
107
|
-
.command("module:make-
|
|
108
|
-
.description("Generate a
|
|
109
|
-
.option("--
|
|
110
|
-
.option("--
|
|
111
|
-
.
|
|
112
|
-
.
|
|
113
|
-
|
|
114
|
-
.
|
|
115
|
-
|
|
116
|
-
.
|
|
117
|
-
.
|
|
118
|
-
|
|
119
|
-
.
|
|
120
|
-
.
|
|
121
|
-
.allowUnknownOption(true)
|
|
122
|
-
.action(async (moduleName) =>
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
.
|
|
129
|
-
.
|
|
130
|
-
.
|
|
131
|
-
|
|
132
|
-
.
|
|
133
|
-
|
|
134
|
-
.
|
|
135
|
-
.
|
|
136
|
-
.option("--
|
|
137
|
-
.
|
|
138
|
-
.
|
|
139
|
-
|
|
140
|
-
|
|
1
|
+
import { runSeed } from "../db/core.mjs";
|
|
2
|
+
import { assertName } from "../utils/naming.mjs";
|
|
3
|
+
import {
|
|
4
|
+
assertModuleHasSeeders,
|
|
5
|
+
cleanModuleTrash,
|
|
6
|
+
deleteModule,
|
|
7
|
+
deleteNotificationModule,
|
|
8
|
+
listModules,
|
|
9
|
+
makeController,
|
|
10
|
+
makeHelper,
|
|
11
|
+
makeJob,
|
|
12
|
+
makeLocalMiddleware,
|
|
13
|
+
makeModel,
|
|
14
|
+
makeModule,
|
|
15
|
+
makeModules,
|
|
16
|
+
makeNotificationModule,
|
|
17
|
+
makeRoute,
|
|
18
|
+
makeSchedule,
|
|
19
|
+
makeSchema,
|
|
20
|
+
makeSeeder,
|
|
21
|
+
makeService,
|
|
22
|
+
makeTest,
|
|
23
|
+
makeType,
|
|
24
|
+
runModuleMigrate
|
|
25
|
+
} from "./core.mjs";
|
|
26
|
+
|
|
27
|
+
/** Register module:* subcommands on the CLI program. */
|
|
28
|
+
export function registerModuleCommands(program, rawArgs) {
|
|
29
|
+
program
|
|
30
|
+
.command("module:make <names...>")
|
|
31
|
+
.description("Create one or more modules with facade, schema, service, controller, route, model, and seeder folders")
|
|
32
|
+
.option("--path <panel>", "Nest the module(s) under a panel folder (e.g. --path=admin)")
|
|
33
|
+
.option("--force", "Overwrite the files of modules that already exist")
|
|
34
|
+
.allowUnknownOption(true)
|
|
35
|
+
.action(async (names) => {
|
|
36
|
+
const result = await makeModules(names, rawArgs.slice(1 + names.length));
|
|
37
|
+
if (result.failed.length) process.exitCode = 1;
|
|
38
|
+
});
|
|
39
|
+
program
|
|
40
|
+
.command("module:make-notification [name]")
|
|
41
|
+
.description("Generate notification backend module (controller, routes, job)")
|
|
42
|
+
.option("--path <panel>", "Nest the module under a panel folder (e.g. --path=admin)")
|
|
43
|
+
.option("--force", "Overwrite the files of a module that already exists")
|
|
44
|
+
.allowUnknownOption(true)
|
|
45
|
+
.action(async (name) => {
|
|
46
|
+
const maybeModule = name && !name.startsWith("--") ? name : "";
|
|
47
|
+
const flagStart = maybeModule ? 2 : 1;
|
|
48
|
+
await makeNotificationModule(maybeModule || "notification", rawArgs.slice(flagStart));
|
|
49
|
+
});
|
|
50
|
+
program
|
|
51
|
+
.command("module:delete-notification [name]")
|
|
52
|
+
.description("Remove notification module (moves to trash)")
|
|
53
|
+
.option("--yes", "Confirm deletion without prompt")
|
|
54
|
+
.option("--dry-run", "Print what would be deleted without executing")
|
|
55
|
+
.option("--path <panel>", "Address a module inside a panel folder (e.g. --path=admin)")
|
|
56
|
+
.allowUnknownOption(true)
|
|
57
|
+
.action(async (name) => {
|
|
58
|
+
const maybeModule = name && !name.startsWith("--") ? name : "";
|
|
59
|
+
const flagStart = maybeModule ? 2 : 1;
|
|
60
|
+
await deleteNotificationModule(maybeModule || "notification", rawArgs.slice(flagStart));
|
|
61
|
+
});
|
|
62
|
+
program
|
|
63
|
+
.command("module:delete <name>")
|
|
64
|
+
.description("Move a module directory to storage trash (soft delete)")
|
|
65
|
+
.option("--yes", "Confirm deletion without prompt")
|
|
66
|
+
.option("--dry-run", "Print what would be deleted without executing")
|
|
67
|
+
.option("--path <panel>", "Address a module inside a panel folder (e.g. --path=admin)")
|
|
68
|
+
.allowUnknownOption(true)
|
|
69
|
+
.action(async (name) => deleteModule(name, rawArgs.slice(2)));
|
|
70
|
+
program
|
|
71
|
+
.command("module:trash:clean [name]")
|
|
72
|
+
.description("Permanently remove entries from module trash storage")
|
|
73
|
+
.option("--yes", "Confirm cleanup without prompt")
|
|
74
|
+
.option("--dry-run", "Print what would be cleaned without executing")
|
|
75
|
+
.option("--path <panel>", "Address a module inside a panel folder (e.g. --path=admin)")
|
|
76
|
+
.allowUnknownOption(true)
|
|
77
|
+
.action(async (name) => {
|
|
78
|
+
const maybeModule = name && !name.startsWith("--") ? name : "";
|
|
79
|
+
const flagStart = maybeModule ? 2 : 1;
|
|
80
|
+
await cleanModuleTrash(maybeModule, rawArgs.slice(flagStart));
|
|
81
|
+
});
|
|
82
|
+
program
|
|
83
|
+
.command("module:make-route <module> [controller]")
|
|
84
|
+
.description("Generate a route file for an existing module")
|
|
85
|
+
.option("--force", "Overwrite existing route file")
|
|
86
|
+
.option("--dry-run", "Print what would be created without executing")
|
|
87
|
+
.option("--path <panel>", "Address a module inside a panel folder (e.g. --path=admin)")
|
|
88
|
+
.allowUnknownOption(true)
|
|
89
|
+
.action(async (moduleName, controller) => makeRoute(moduleName, controller, rawArgs.slice(controller ? 3 : 2)));
|
|
90
|
+
program
|
|
91
|
+
.command("module:make-controller <module> [name]")
|
|
92
|
+
.description("Generate a controller for an existing module")
|
|
93
|
+
.option("--force", "Overwrite existing controller file")
|
|
94
|
+
.option("--dry-run", "Print what would be created without executing")
|
|
95
|
+
.option("--path <panel>", "Address a module inside a panel folder (e.g. --path=admin)")
|
|
96
|
+
.allowUnknownOption(true)
|
|
97
|
+
.action(async (moduleName, name) => makeController(moduleName, name, rawArgs.slice(name ? 3 : 2)));
|
|
98
|
+
program
|
|
99
|
+
.command("module:make-schema <module> [name]")
|
|
100
|
+
.description("Generate a schema file for an existing module")
|
|
101
|
+
.option("--force", "Overwrite existing schema file")
|
|
102
|
+
.option("--dry-run", "Print what would be created without executing")
|
|
103
|
+
.option("--path <panel>", "Address a module inside a panel folder (e.g. --path=admin)")
|
|
104
|
+
.allowUnknownOption(true)
|
|
105
|
+
.action(async (moduleName, name) => makeSchema(moduleName, name, rawArgs.slice(name ? 3 : 2)));
|
|
106
|
+
program
|
|
107
|
+
.command("module:make-service <module> [name]")
|
|
108
|
+
.description("Generate a service file for an existing module")
|
|
109
|
+
.option("--with-model", "Query database/models/<name>.ts instead of returning empty defaults")
|
|
110
|
+
.option("--force", "Overwrite existing service file")
|
|
111
|
+
.option("--dry-run", "Print what would be created without executing")
|
|
112
|
+
.option("--path <panel>", "Address a module inside a panel folder (e.g. --path=admin)")
|
|
113
|
+
.allowUnknownOption(true)
|
|
114
|
+
.action(async (moduleName, name) => makeService(moduleName, name, rawArgs.slice(name ? 3 : 2)));
|
|
115
|
+
program
|
|
116
|
+
.command("module:make-helper <module> [name]")
|
|
117
|
+
.description("Generate a helper file in the module's helpers folder")
|
|
118
|
+
.option("--force", "Overwrite existing helper file")
|
|
119
|
+
.option("--dry-run", "Print what would be created without executing")
|
|
120
|
+
.option("--path <panel>", "Address a module inside a panel folder (e.g. --path=admin)")
|
|
121
|
+
.allowUnknownOption(true)
|
|
122
|
+
.action(async (moduleName, name) => makeHelper(moduleName, name, rawArgs.slice(name ? 3 : 2)));
|
|
123
|
+
program
|
|
124
|
+
.command("module:make-middleware <module> [name]")
|
|
125
|
+
.description("Generate a module-local middleware file for an existing module")
|
|
126
|
+
.option("--force", "Overwrite existing middleware file")
|
|
127
|
+
.option("--dry-run", "Print what would be created without executing")
|
|
128
|
+
.option("--path <panel>", "Address a module inside a panel folder (e.g. --path=admin)")
|
|
129
|
+
.allowUnknownOption(true)
|
|
130
|
+
.action(async (moduleName, name) => makeLocalMiddleware(moduleName, name, rawArgs.slice(name ? 3 : 2)));
|
|
131
|
+
program
|
|
132
|
+
.command("module:make-type <module> [name]")
|
|
133
|
+
.description("Generate a types file for an existing module")
|
|
134
|
+
.option("--force", "Overwrite existing types file")
|
|
135
|
+
.option("--dry-run", "Print what would be created without executing")
|
|
136
|
+
.option("--path <panel>", "Address a module inside a panel folder (e.g. --path=admin)")
|
|
137
|
+
.allowUnknownOption(true)
|
|
138
|
+
.action(async (moduleName, name) => makeType(moduleName, name, rawArgs.slice(name ? 3 : 2)));
|
|
139
|
+
program
|
|
140
|
+
.command("module:make-model <module> [name]")
|
|
141
|
+
.description("Generate a model file for an existing module")
|
|
142
|
+
.option("--force", "Overwrite existing model file")
|
|
143
|
+
.option("--dry-run", "Print what would be created without executing")
|
|
144
|
+
.option("--path <panel>", "Address a module inside a panel folder (e.g. --path=admin)")
|
|
145
|
+
.allowUnknownOption(true)
|
|
146
|
+
.action(async (moduleName, name) => makeModel(moduleName, name, rawArgs.slice(name ? 3 : 2)));
|
|
147
|
+
program
|
|
148
|
+
.command("module:make-seeder <module> [name]")
|
|
149
|
+
.description("Generate a seeder file for an existing module model")
|
|
150
|
+
.option("--force", "Overwrite existing seeder file")
|
|
151
|
+
.option("--dry-run", "Print what would be created without executing")
|
|
152
|
+
.option("--path <panel>", "Address a module inside a panel folder (e.g. --path=admin)")
|
|
153
|
+
.allowUnknownOption(true)
|
|
154
|
+
.action(async (moduleName, name) => makeSeeder(moduleName, name, rawArgs.slice(name ? 3 : 2)));
|
|
155
|
+
program
|
|
156
|
+
.command("module:make-job <module> [name]")
|
|
157
|
+
.description("Generate a job file for an existing module")
|
|
158
|
+
.option("--force", "Overwrite existing job file")
|
|
159
|
+
.option("--dry-run", "Print what would be created without executing")
|
|
160
|
+
.option("--path <panel>", "Address a module inside a panel folder (e.g. --path=admin)")
|
|
161
|
+
.allowUnknownOption(true)
|
|
162
|
+
.action(async (moduleName, name) => makeJob(moduleName, name, rawArgs.slice(name ? 3 : 2)));
|
|
163
|
+
program
|
|
164
|
+
.command("module:make-console <module> [name]")
|
|
165
|
+
.description("Generate a scheduler/console file for an existing module")
|
|
166
|
+
.option("--force", "Overwrite existing console file")
|
|
167
|
+
.option("--dry-run", "Print what would be created without executing")
|
|
168
|
+
.option("--path <panel>", "Address a module inside a panel folder (e.g. --path=admin)")
|
|
169
|
+
.allowUnknownOption(true)
|
|
170
|
+
.action(async (moduleName, name) => makeSchedule(moduleName, name, rawArgs.slice(name ? 3 : 2)));
|
|
171
|
+
program
|
|
172
|
+
.command("module:list")
|
|
173
|
+
.description("List all discovered modules")
|
|
174
|
+
.option("--path <panel>", "Address a module inside a panel folder (e.g. --path=admin)")
|
|
175
|
+
.allowUnknownOption(true)
|
|
176
|
+
.action(async () => listModules());
|
|
177
|
+
program
|
|
178
|
+
.command("module:seed <module>")
|
|
179
|
+
.description("Run seeders for one module")
|
|
180
|
+
.option("--path <panel>", "Address a module inside a panel folder (e.g. --path=admin)")
|
|
181
|
+
.allowUnknownOption(true)
|
|
182
|
+
.action(async (moduleName) => {
|
|
183
|
+
const normalized = assertName(moduleName, "Module name");
|
|
184
|
+
await assertModuleHasSeeders(normalized);
|
|
185
|
+
await runSeed(normalized);
|
|
186
|
+
});
|
|
187
|
+
program
|
|
188
|
+
.command("module:migrate <module>")
|
|
189
|
+
.description("Generate module-only schema, generate migration, then run migrate")
|
|
190
|
+
.option("--keep-temp", "Keep temporary schema file after migration")
|
|
191
|
+
.option("--path <panel>", "Address a module inside a panel folder (e.g. --path=admin)")
|
|
192
|
+
.allowUnknownOption(true)
|
|
193
|
+
.action(async (moduleName) => runModuleMigrate(moduleName, rawArgs));
|
|
194
|
+
program
|
|
195
|
+
.command("module:make-test <module> [name]")
|
|
196
|
+
.description("Generate a unit test file for a module")
|
|
197
|
+
.option("--force", "Overwrite existing test file")
|
|
198
|
+
.option("--dry-run", "Print what would be created without executing")
|
|
199
|
+
.option("--path <panel>", "Address a module inside a panel folder (e.g. --path=admin)")
|
|
200
|
+
.allowUnknownOption(true)
|
|
201
|
+
.action(async (moduleName, name) => makeTest(moduleName, name, rawArgs.slice(name ? 3 : 2)));
|
|
202
|
+
}
|
|
@@ -120,7 +120,7 @@ function serveRedisUnavailablePage(port, endpoint) {
|
|
|
120
120
|
</html>
|
|
121
121
|
`;
|
|
122
122
|
|
|
123
|
-
return new Promise((
|
|
123
|
+
return new Promise((_resolve, reject) => {
|
|
124
124
|
const server = http.createServer((_req, res) => {
|
|
125
125
|
res.writeHead(200, { "content-type": "text/html; charset=utf-8" });
|
|
126
126
|
res.end(body);
|
|
@@ -540,4 +540,3 @@ export async function clearViteCache() {
|
|
|
540
540
|
|
|
541
541
|
console.log("Vite cache cleared.");
|
|
542
542
|
}
|
|
543
|
-
|
|
@@ -1,47 +1,73 @@
|
|
|
1
1
|
import type { Request, Response } from "express";
|
|
2
2
|
import { HttpStatusCodes } from "@/framework/facade.js";
|
|
3
|
+
import { {{controller}}Service } from "@/modules/{{module}}/services/{{controller}}.js";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
|
-
* Why: Returns
|
|
6
|
+
* Why: Returns every {{controller}} row for list screens.
|
|
6
7
|
* When: Used by GET list endpoint.
|
|
7
8
|
* Where: GET /{{controller}} route.
|
|
8
9
|
*/
|
|
9
10
|
export const index = async (_req: Request, res: Response) => {
|
|
10
|
-
|
|
11
|
+
const data = await {{controller}}Service.list();
|
|
12
|
+
|
|
13
|
+
res.json({ message: "{{controller}} list fetched successfully", data });
|
|
11
14
|
};
|
|
12
15
|
|
|
13
16
|
/**
|
|
14
|
-
* Why: Returns one
|
|
17
|
+
* Why: Returns one {{controller}} row by validated route id.
|
|
15
18
|
* When: Used by detail screens or fetch-by-id calls.
|
|
16
19
|
* Where: GET /{{controller}}/{id} route.
|
|
17
20
|
*/
|
|
18
21
|
export const show = async (req: Request, res: Response) => {
|
|
19
|
-
|
|
22
|
+
const data = await {{controller}}Service.findOne(Number(req.params.id));
|
|
23
|
+
|
|
24
|
+
if (!data) {
|
|
25
|
+
res.status(HttpStatusCodes.NOT_FOUND).json({ message: "{{controller}} not found" });
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
res.json({ message: "{{controller}} fetched successfully", data });
|
|
20
30
|
};
|
|
21
31
|
|
|
22
32
|
/**
|
|
23
|
-
* Why: Creates a new
|
|
33
|
+
* Why: Creates a new {{controller}} row from a validated request body.
|
|
24
34
|
* When: Used by create form submissions.
|
|
25
35
|
* Where: POST /{{controller}} route.
|
|
26
36
|
*/
|
|
27
|
-
export const store = async (
|
|
28
|
-
|
|
37
|
+
export const store = async (req: Request, res: Response) => {
|
|
38
|
+
const data = await {{controller}}Service.create(req.body);
|
|
39
|
+
|
|
40
|
+
res.status(HttpStatusCodes.CREATED).json({ message: "{{controller}} created successfully", data });
|
|
29
41
|
};
|
|
30
42
|
|
|
31
43
|
/**
|
|
32
|
-
* Why: Updates an existing
|
|
44
|
+
* Why: Updates an existing {{controller}} row using id + body validation.
|
|
33
45
|
* When: Used by edit/update form submissions.
|
|
34
46
|
* Where: PUT/PATCH /{{controller}}/{id} route.
|
|
35
47
|
*/
|
|
36
|
-
export const update = async (
|
|
37
|
-
|
|
48
|
+
export const update = async (req: Request, res: Response) => {
|
|
49
|
+
const data = await {{controller}}Service.update(Number(req.params.id), req.body);
|
|
50
|
+
|
|
51
|
+
if (!data) {
|
|
52
|
+
res.status(HttpStatusCodes.NOT_FOUND).json({ message: "{{controller}} not found" });
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
res.json({ message: "{{controller}} updated successfully", data });
|
|
38
57
|
};
|
|
39
58
|
|
|
40
59
|
/**
|
|
41
|
-
* Why: Deletes one
|
|
60
|
+
* Why: Deletes one {{controller}} row by validated route id.
|
|
42
61
|
* When: Used by delete actions.
|
|
43
62
|
* Where: DELETE /{{controller}}/{id} route.
|
|
44
63
|
*/
|
|
45
|
-
export const destroy = async (
|
|
46
|
-
|
|
47
|
-
|
|
64
|
+
export const destroy = async (req: Request, res: Response) => {
|
|
65
|
+
const data = await {{controller}}Service.remove(Number(req.params.id));
|
|
66
|
+
|
|
67
|
+
if (!data) {
|
|
68
|
+
res.status(HttpStatusCodes.NOT_FOUND).json({ message: "{{controller}} not found" });
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
res.json({ message: "{{controller}} deleted successfully", data });
|
|
73
|
+
};
|
|
@@ -1,48 +1,73 @@
|
|
|
1
1
|
import type { Request, Response } from "express";
|
|
2
2
|
import { HttpStatusCodes } from "@/framework/facade.js";
|
|
3
|
-
import { {{
|
|
3
|
+
import { {{controller}}Service } from "@/modules/{{module}}/services/{{controller}}.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Why: Returns
|
|
6
|
+
* Why: Returns every {{controller}} row for list screens.
|
|
7
7
|
* When: Used by GET list endpoint.
|
|
8
8
|
* Where: GET /{{controller}} route.
|
|
9
9
|
*/
|
|
10
10
|
export const index = async (_req: Request, res: Response) => {
|
|
11
|
-
|
|
11
|
+
const data = await {{controller}}Service.list();
|
|
12
|
+
|
|
13
|
+
res.json({ message: "{{controller}} list fetched successfully", data });
|
|
12
14
|
};
|
|
13
15
|
|
|
14
16
|
/**
|
|
15
|
-
* Why: Returns one
|
|
17
|
+
* Why: Returns one {{controller}} row by validated route id.
|
|
16
18
|
* When: Used by detail screens or fetch-by-id calls.
|
|
17
19
|
* Where: GET /{{controller}}/{id} route.
|
|
18
20
|
*/
|
|
19
21
|
export const show = async (req: Request, res: Response) => {
|
|
20
|
-
|
|
22
|
+
const data = await {{controller}}Service.findOne(Number(req.params.id));
|
|
23
|
+
|
|
24
|
+
if (!data) {
|
|
25
|
+
res.status(HttpStatusCodes.NOT_FOUND).json({ message: "{{controller}} not found" });
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
res.json({ message: "{{controller}} fetched successfully", data });
|
|
21
30
|
};
|
|
22
31
|
|
|
23
32
|
/**
|
|
24
|
-
* Why: Creates a new
|
|
33
|
+
* Why: Creates a new {{controller}} row from a validated request body.
|
|
25
34
|
* When: Used by create form submissions.
|
|
26
35
|
* Where: POST /{{controller}} route.
|
|
27
36
|
*/
|
|
28
|
-
export const store = async (
|
|
29
|
-
|
|
37
|
+
export const store = async (req: Request, res: Response) => {
|
|
38
|
+
const data = await {{controller}}Service.create(req.body);
|
|
39
|
+
|
|
40
|
+
res.status(HttpStatusCodes.CREATED).json({ message: "{{controller}} created successfully", data });
|
|
30
41
|
};
|
|
31
42
|
|
|
32
43
|
/**
|
|
33
|
-
* Why: Updates an existing
|
|
44
|
+
* Why: Updates an existing {{controller}} row using id + body validation.
|
|
34
45
|
* When: Used by edit/update form submissions.
|
|
35
46
|
* Where: PUT/PATCH /{{controller}}/{id} route.
|
|
36
47
|
*/
|
|
37
|
-
export const update = async (
|
|
38
|
-
|
|
48
|
+
export const update = async (req: Request, res: Response) => {
|
|
49
|
+
const data = await {{controller}}Service.update(Number(req.params.id), req.body);
|
|
50
|
+
|
|
51
|
+
if (!data) {
|
|
52
|
+
res.status(HttpStatusCodes.NOT_FOUND).json({ message: "{{controller}} not found" });
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
res.json({ message: "{{controller}} updated successfully", data });
|
|
39
57
|
};
|
|
40
58
|
|
|
41
59
|
/**
|
|
42
|
-
* Why: Deletes one
|
|
60
|
+
* Why: Deletes one {{controller}} row by validated route id.
|
|
43
61
|
* When: Used by delete actions.
|
|
44
62
|
* Where: DELETE /{{controller}}/{id} route.
|
|
45
63
|
*/
|
|
46
|
-
export const destroy = async (
|
|
47
|
-
|
|
48
|
-
|
|
64
|
+
export const destroy = async (req: Request, res: Response) => {
|
|
65
|
+
const data = await {{controller}}Service.remove(Number(req.params.id));
|
|
66
|
+
|
|
67
|
+
if (!data) {
|
|
68
|
+
res.status(HttpStatusCodes.NOT_FOUND).json({ message: "{{controller}} not found" });
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
res.json({ message: "{{controller}} deleted successfully", data });
|
|
73
|
+
};
|