arkos 1.2.18-test → 1.2.20-test
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/dist/cjs/modules/auth/auth.service.js.map +1 -1
- package/dist/cjs/utils/cli/utils/cli.helpers.js +2 -10
- package/dist/cjs/utils/cli/utils/cli.helpers.js.map +1 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-middlewares.js +33 -66
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-middlewares.js.map +1 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js +16 -10
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js.map +1 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-router-template.js +5 -0
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-router-template.js.map +1 -1
- package/dist/esm/app.js +1 -1
- package/dist/esm/exports/auth/index.js +1 -1
- package/dist/esm/exports/controllers/index.js +2 -2
- package/dist/esm/exports/error-handler/index.js +2 -2
- package/dist/esm/exports/index.js +2 -2
- package/dist/esm/exports/middlewares/index.js +1 -1
- package/dist/esm/exports/prisma/index.js +1 -1
- package/dist/esm/exports/services/index.js +4 -4
- package/dist/esm/exports/utils/index.js +2 -2
- package/dist/esm/exports/validation/index.js +2 -2
- package/dist/esm/modules/auth/auth.controller.js +7 -7
- package/dist/esm/modules/auth/auth.router.js +6 -6
- package/dist/esm/modules/auth/auth.service.js +6 -6
- package/dist/esm/modules/auth/auth.service.js.map +1 -1
- package/dist/esm/modules/auth/utils/helpers/auth.controller.helpers.js +2 -2
- package/dist/esm/modules/base/base.controller.js +7 -7
- package/dist/esm/modules/base/base.middlewares.js +6 -6
- package/dist/esm/modules/base/base.router.js +4 -4
- package/dist/esm/modules/base/base.service.js +6 -6
- package/dist/esm/modules/base/utils/helpers/base.controller.helpers.js +1 -1
- package/dist/esm/modules/base/utils/helpers/base.middlewares.helpers.js +1 -1
- package/dist/esm/modules/base/utils/helpers/base.router.helpers.js +6 -6
- package/dist/esm/modules/base/utils/helpers/base.service.helpers.js +1 -1
- package/dist/esm/modules/email/email.service.js +2 -2
- package/dist/esm/modules/error-handler/error-handler.controller.js +3 -3
- package/dist/esm/modules/error-handler/utils/error-handler.helpers.js +1 -1
- package/dist/esm/modules/file-upload/file-upload.controller.js +7 -7
- package/dist/esm/modules/file-upload/file-upload.router.js +5 -5
- package/dist/esm/modules/file-upload/file-upload.service.js +5 -5
- package/dist/esm/modules/file-upload/utils/helpers/file-upload.helpers.js +2 -2
- package/dist/esm/modules/swagger/swagger.router.js +2 -2
- package/dist/esm/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js +2 -2
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js +3 -3
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.js +2 -2
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schema.js +2 -2
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes.js +2 -2
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes.js +3 -3
- package/dist/esm/modules/swagger/utils/helpers/swagger.router.helpers.js +9 -9
- package/dist/esm/server.js +1 -1
- package/dist/esm/utils/cli/build.js +4 -4
- package/dist/esm/utils/cli/dev.js +5 -5
- package/dist/esm/utils/cli/generate.js +4 -4
- package/dist/esm/utils/cli/index.js +5 -5
- package/dist/esm/utils/cli/start.js +4 -4
- package/dist/esm/utils/cli/utils/cli.helpers.js +4 -12
- package/dist/esm/utils/cli/utils/cli.helpers.js.map +1 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-auth-configs-template.js +1 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-middlewares.js +34 -67
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-middlewares.js.map +1 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js +18 -12
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js.map +1 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-router-template.js +6 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-router-template.js.map +1 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-service-template.js +2 -2
- package/dist/esm/utils/cli/utils/template-generators.js +6 -6
- package/dist/esm/utils/features/api.features.js +4 -4
- package/dist/esm/utils/features/change-case.features.js +1 -1
- package/dist/esm/utils/helpers/models.helpers.js +4 -4
- package/dist/esm/utils/helpers/prisma.helpers.js +4 -4
- package/dist/esm/utils/validate-dto.js +1 -1
- package/dist/esm/utils/validate-schema.js +1 -1
- package/package.json +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import { spawn } from "child_process";
|
|
4
|
-
import { getVersion } from "./utils/cli.helpers
|
|
5
|
-
import { loadEnvironmentVariables } from "../dotenv.helpers
|
|
6
|
-
import { importModule } from "../helpers/global.helpers
|
|
7
|
-
import { fullCleanCwd } from "../helpers/fs.helpers
|
|
4
|
+
import { getVersion } from "./utils/cli.helpers";
|
|
5
|
+
import { loadEnvironmentVariables } from "../dotenv.helpers";
|
|
6
|
+
import { importModule } from "../helpers/global.helpers";
|
|
7
|
+
import { fullCleanCwd } from "../helpers/fs.helpers";
|
|
8
8
|
let child = null;
|
|
9
9
|
let envFiles;
|
|
10
10
|
export async function startCommand(options = {}) {
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
|
-
import { killDevelopmentServerChildProcess } from "../dev
|
|
3
|
-
import { killProductionServerChildProcess } from "../start
|
|
2
|
+
import { killDevelopmentServerChildProcess } from "../dev";
|
|
3
|
+
import { killProductionServerChildProcess } from "../start";
|
|
4
4
|
import path from "path";
|
|
5
|
-
import { fileURLToPath } from "url";
|
|
6
|
-
import { dirname } from "path";
|
|
7
5
|
export function ensureDirectoryExists(dirPath) {
|
|
8
6
|
if (!fs.existsSync(dirPath)) {
|
|
9
7
|
fs.mkdirSync(dirPath, { recursive: true });
|
|
@@ -14,14 +12,8 @@ export function killServerChildProcess() {
|
|
|
14
12
|
killProductionServerChildProcess();
|
|
15
13
|
}
|
|
16
14
|
export function getVersion() {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
currentDir = __dirname;
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
currentDir = dirname(fileURLToPath(import.meta.url));
|
|
23
|
-
}
|
|
24
|
-
const packageJson = JSON.parse(fs.readFileSync(path.join(currentDir, "../../../../../package.json"), "utf8") || "{}");
|
|
15
|
+
const packageJsonPath = path.resolve(__dirname || process.cwd(), "../../../../../package.json");
|
|
16
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8") || "{}");
|
|
25
17
|
return packageJson?.version || "1.0.0";
|
|
26
18
|
}
|
|
27
19
|
//# sourceMappingURL=cli.helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.helpers.js","sourceRoot":"","sources":["../../../../../src/utils/cli/utils/cli.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,iCAAiC,EAAE,MAAM,QAAQ,CAAC;AAC3D,OAAO,EAAE,gCAAgC,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,IAAI,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.helpers.js","sourceRoot":"","sources":["../../../../../src/utils/cli/utils/cli.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,iCAAiC,EAAE,MAAM,QAAQ,CAAC;AAC3D,OAAO,EAAE,gCAAgC,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,IAAI,MAAM,MAAM,CAAC;AAIxB,MAAM,UAAU,qBAAqB,CAAC,OAAe;IACnD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5B,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7C,CAAC;AACH,CAAC;AAED,MAAM,UAAU,sBAAsB;IACpC,iCAAiC,EAAE,CAAC;IACpC,gCAAgC,EAAE,CAAC;AACrC,CAAC;AAsBD,MAAM,UAAU,UAAU;IAExB,MAAM,eAAe,GAAG,IAAI,CAAC,OAAO,CAClC,SAAS,IAAI,OAAO,CAAC,GAAG,EAAE,EAC1B,6BAA6B,CAC9B,CAAC;IAEF,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAC5B,EAAE,CAAC,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,IAAI,IAAI,CACjD,CAAC;IACF,OAAO,WAAW,EAAE,OAAO,IAAI,OAAO,CAAC;AACzC,CAAC","sourcesContent":["import fs from \"fs\";\nimport { killDevelopmentServerChildProcess } from \"../dev\";\nimport { killProductionServerChildProcess } from \"../start\";\nimport path from \"path\";\n// import { fileURLToPath } from \"url\";\n// import { dirname } from \"path\";\n\nexport function ensureDirectoryExists(dirPath: string): void {\n if (!fs.existsSync(dirPath)) {\n fs.mkdirSync(dirPath, { recursive: true });\n }\n}\n\nexport function killServerChildProcess() {\n killDevelopmentServerChildProcess();\n killProductionServerChildProcess();\n}\n\n// export function getVersion() {\n// let currentDir: string;\n// // @ts-ignore\n// if (typeof __dirname !== \"undefined\") {\n// // @ts-ignore\n// currentDir = __dirname;\n// } else {\n// // @ts-ignore\n// currentDir = dirname(fileURLToPath((import.meta as any).url));\n// }\n\n// const packageJson = JSON.parse(\n// fs.readFileSync(\n// path.join(currentDir, \"../../../../../package.json\"),\n// \"utf8\"\n// ) || \"{}\"\n// );\n// return packageJson?.version || \"1.0.0\";\n// }\n\nexport function getVersion() {\n // Just use process.cwd() or a relative path that works from the compiled location\n const packageJsonPath = path.resolve(\n __dirname || process.cwd(),\n \"../../../../../package.json\"\n );\n\n const packageJson = JSON.parse(\n fs.readFileSync(packageJsonPath, \"utf8\") || \"{}\"\n );\n return packageJson?.version || \"1.0.0\";\n}\n"]}
|
package/dist/esm/utils/cli/utils/template-generator/templates/generate-auth-configs-template.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getUserFileExtension } from "../../../../helpers/fs.helpers
|
|
1
|
+
import { getUserFileExtension } from "../../../../helpers/fs.helpers";
|
|
2
2
|
export function generateAuthConfigsTemplate(options) {
|
|
3
3
|
const { modelName } = options;
|
|
4
4
|
const ext = getUserFileExtension();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getUserFileExtension } from "../../../../helpers/fs.helpers
|
|
1
|
+
import { getUserFileExtension } from "../../../../helpers/fs.helpers";
|
|
2
2
|
export function generateMiddlewaresTemplate(options) {
|
|
3
3
|
const { modelName } = options;
|
|
4
4
|
const ext = getUserFileExtension();
|
|
@@ -20,246 +20,213 @@ import { catchAsync } from "arkos/error-handler";`
|
|
|
20
20
|
if (isAuth) {
|
|
21
21
|
return `${baseImports}
|
|
22
22
|
|
|
23
|
-
// export const beforeGetMe =
|
|
23
|
+
// export const beforeGetMe =
|
|
24
24
|
// async (${functionParams}) => {
|
|
25
25
|
// // Your logic here
|
|
26
26
|
// next();
|
|
27
27
|
// }
|
|
28
|
-
// );
|
|
29
28
|
|
|
30
|
-
// export const afterGetMe =
|
|
29
|
+
// export const afterGetMe =
|
|
31
30
|
// async (${functionParams}) => {
|
|
32
31
|
// // Your logic here
|
|
33
32
|
// next();
|
|
34
33
|
// }
|
|
35
|
-
// );
|
|
36
34
|
|
|
37
|
-
// export const beforeLogin =
|
|
35
|
+
// export const beforeLogin =
|
|
38
36
|
// async (${functionParams}) => {
|
|
39
37
|
// // Your logic here
|
|
40
38
|
// next();
|
|
41
39
|
// }
|
|
42
|
-
// );
|
|
43
40
|
|
|
44
|
-
// export const afterLogin =
|
|
41
|
+
// export const afterLogin =
|
|
45
42
|
// async (${functionParams}) => {
|
|
46
43
|
// // Your logic here
|
|
47
44
|
// next();
|
|
48
45
|
// }
|
|
49
|
-
// );
|
|
50
46
|
|
|
51
|
-
// export const beforeLogout =
|
|
47
|
+
// export const beforeLogout =
|
|
52
48
|
// async (${functionParams}) => {
|
|
53
49
|
// // Your logic here
|
|
54
50
|
// next();
|
|
55
51
|
// }
|
|
56
|
-
// );
|
|
57
52
|
|
|
58
|
-
// export const afterLogout =
|
|
53
|
+
// export const afterLogout =
|
|
59
54
|
// async (${functionParams}) => {
|
|
60
55
|
// // Your logic here
|
|
61
56
|
// next();
|
|
62
57
|
// }
|
|
63
|
-
// );
|
|
64
58
|
|
|
65
|
-
// export const beforeSignup =
|
|
59
|
+
// export const beforeSignup =
|
|
66
60
|
// async (${functionParams}) => {
|
|
67
61
|
// // Your logic here
|
|
68
62
|
// next();
|
|
69
63
|
// }
|
|
70
|
-
// );
|
|
71
64
|
|
|
72
|
-
// export const afterSignup =
|
|
65
|
+
// export const afterSignup =
|
|
73
66
|
// async (${functionParams}) => {
|
|
74
67
|
// // Your logic here
|
|
75
68
|
// next();
|
|
76
69
|
// }
|
|
77
|
-
// );
|
|
78
70
|
|
|
79
|
-
// export const beforeUpdatePassword =
|
|
71
|
+
// export const beforeUpdatePassword =
|
|
80
72
|
// async (${functionParams}) => {
|
|
81
73
|
// // Your logic here
|
|
82
74
|
// next();
|
|
83
75
|
// }
|
|
84
|
-
// );
|
|
85
76
|
|
|
86
|
-
// export const afterUpdatePassword =
|
|
77
|
+
// export const afterUpdatePassword =
|
|
87
78
|
// async (${functionParams}) => {
|
|
88
79
|
// // Your logic here
|
|
89
80
|
// next();
|
|
90
81
|
// }
|
|
91
|
-
// );
|
|
92
82
|
`;
|
|
93
83
|
}
|
|
94
84
|
if (isFileUpload) {
|
|
95
85
|
return `${baseImports}
|
|
96
86
|
|
|
97
87
|
|
|
98
|
-
// export const beforeFindFile =
|
|
88
|
+
// export const beforeFindFile =
|
|
99
89
|
// async (${functionParams}) => {
|
|
100
90
|
// // Your logic here
|
|
101
91
|
// next();
|
|
102
92
|
// }
|
|
103
|
-
// );
|
|
104
93
|
|
|
105
94
|
// There is not afterFindFile: because the main handler is handleded by express.static()
|
|
106
95
|
|
|
107
|
-
// export const beforeUploadFile =
|
|
96
|
+
// export const beforeUploadFile =
|
|
108
97
|
// async (${functionParams}) => {
|
|
109
98
|
// // Your logic here
|
|
110
99
|
// next();
|
|
111
100
|
// }
|
|
112
|
-
// );
|
|
113
101
|
|
|
114
|
-
// export const afterUploadFile =
|
|
102
|
+
// export const afterUploadFile =
|
|
115
103
|
// async (${functionParams}) => {
|
|
116
104
|
// // Your logic here
|
|
117
105
|
// next();
|
|
118
106
|
// }
|
|
119
|
-
// );
|
|
120
107
|
|
|
121
|
-
// export const beforeUpdateFile =
|
|
108
|
+
// export const beforeUpdateFile =
|
|
122
109
|
// async (${functionParams}) => {
|
|
123
110
|
// // Your logic here
|
|
124
111
|
// next();
|
|
125
112
|
// }
|
|
126
|
-
// );
|
|
127
113
|
|
|
128
|
-
// export const afterUpdateFile =
|
|
114
|
+
// export const afterUpdateFile =
|
|
129
115
|
// async (${functionParams}) => {
|
|
130
116
|
// // Your logic here
|
|
131
117
|
// next();
|
|
132
118
|
// }
|
|
133
|
-
// );
|
|
134
119
|
|
|
135
|
-
// export const beforeDeleteFile =
|
|
120
|
+
// export const beforeDeleteFile =
|
|
136
121
|
// async (${functionParams}) => {
|
|
137
122
|
// // Your logic here
|
|
138
123
|
// next();
|
|
139
124
|
// }
|
|
140
|
-
// );
|
|
141
125
|
|
|
142
|
-
// export const afterDeleteFile =
|
|
126
|
+
// export const afterDeleteFile =
|
|
143
127
|
// async (${functionParams}) => {
|
|
144
128
|
// // Your logic here
|
|
145
129
|
// next();
|
|
146
130
|
// }
|
|
147
|
-
// );
|
|
148
131
|
`;
|
|
149
132
|
}
|
|
150
133
|
return `${baseImports}
|
|
151
134
|
|
|
152
|
-
// export const beforeCreateOne =
|
|
135
|
+
// export const beforeCreateOne =
|
|
153
136
|
// async (${functionParams}) => {
|
|
154
137
|
// // Your logic here
|
|
155
138
|
// next();
|
|
156
139
|
// }
|
|
157
|
-
// );
|
|
158
140
|
|
|
159
|
-
// export const afterCreateOne =
|
|
141
|
+
// export const afterCreateOne =
|
|
160
142
|
// async (${functionParams}) => {
|
|
161
143
|
// // Your logic here
|
|
162
144
|
// next();
|
|
163
145
|
// }
|
|
164
|
-
// );
|
|
165
146
|
|
|
166
|
-
// export const beforeFindOne =
|
|
147
|
+
// export const beforeFindOne =
|
|
167
148
|
// async (${functionParams}) => {
|
|
168
149
|
// // Your logic here
|
|
169
150
|
// next();
|
|
170
151
|
// }
|
|
171
|
-
// );
|
|
172
152
|
|
|
173
|
-
// export const afterFindOne =
|
|
153
|
+
// export const afterFindOne =
|
|
174
154
|
// async (${functionParams}) => {
|
|
175
155
|
// // Your logic here
|
|
176
156
|
// next();
|
|
177
157
|
// }
|
|
178
|
-
// );
|
|
179
158
|
|
|
180
|
-
// export const beforeFindMany =
|
|
159
|
+
// export const beforeFindMany =
|
|
181
160
|
// async (${functionParams}) => {
|
|
182
161
|
// // Your logic here
|
|
183
162
|
// next();
|
|
184
163
|
// }
|
|
185
|
-
// );
|
|
186
164
|
|
|
187
|
-
// export const afterFindMany =
|
|
165
|
+
// export const afterFindMany =
|
|
188
166
|
// async (${functionParams}) => {
|
|
189
167
|
// // Your logic here
|
|
190
168
|
// next();
|
|
191
169
|
// }
|
|
192
|
-
// );
|
|
193
170
|
|
|
194
|
-
// export const beforeUpdateOne =
|
|
171
|
+
// export const beforeUpdateOne =
|
|
195
172
|
// async (${functionParams}) => {
|
|
196
173
|
// // Your logic here
|
|
197
174
|
// next();
|
|
198
175
|
// }
|
|
199
|
-
// );
|
|
200
176
|
|
|
201
|
-
// export const afterUpdateOne =
|
|
177
|
+
// export const afterUpdateOne =
|
|
202
178
|
// async (${functionParams}) => {
|
|
203
179
|
// // Your logic here
|
|
204
180
|
// next();
|
|
205
181
|
// }
|
|
206
|
-
// );
|
|
207
182
|
|
|
208
|
-
// export const beforeDeleteOne =
|
|
183
|
+
// export const beforeDeleteOne =
|
|
209
184
|
// async (${functionParams}) => {
|
|
210
185
|
// // Your logic here
|
|
211
186
|
// next();
|
|
212
187
|
// }
|
|
213
|
-
// );
|
|
214
188
|
|
|
215
|
-
// export const afterDeleteOne =
|
|
189
|
+
// export const afterDeleteOne =
|
|
216
190
|
// async (${functionParams}) => {
|
|
217
191
|
// // Your logic here
|
|
218
192
|
// next();
|
|
219
193
|
// }
|
|
220
|
-
// );
|
|
221
194
|
|
|
222
|
-
// export const beforeCreateMany =
|
|
195
|
+
// export const beforeCreateMany =
|
|
223
196
|
// async (${functionParams}) => {
|
|
224
197
|
// // Your logic here
|
|
225
198
|
// next();
|
|
226
199
|
// }
|
|
227
|
-
// );
|
|
228
200
|
|
|
229
|
-
// export const afterCreateMany =
|
|
201
|
+
// export const afterCreateMany =
|
|
230
202
|
// async (${functionParams}) => {
|
|
231
203
|
// // Your logic here
|
|
232
204
|
// next();
|
|
233
205
|
// }
|
|
234
|
-
// );
|
|
235
206
|
|
|
236
|
-
// export const beforeUpdateMany =
|
|
207
|
+
// export const beforeUpdateMany =
|
|
237
208
|
// async (${functionParams}) => {
|
|
238
209
|
// // Your logic here
|
|
239
210
|
// next();
|
|
240
211
|
// }
|
|
241
|
-
// );
|
|
242
212
|
|
|
243
|
-
// export const afterUpdateMany =
|
|
213
|
+
// export const afterUpdateMany =
|
|
244
214
|
// async (${functionParams}) => {
|
|
245
215
|
// // Your logic here
|
|
246
216
|
// next();
|
|
247
217
|
// }
|
|
248
|
-
// );
|
|
249
218
|
|
|
250
|
-
// export const beforeDeleteMany =
|
|
219
|
+
// export const beforeDeleteMany =
|
|
251
220
|
// async (${functionParams}) => {
|
|
252
221
|
// // Your logic here
|
|
253
222
|
// next();
|
|
254
223
|
// }
|
|
255
|
-
// );
|
|
256
224
|
|
|
257
|
-
// export const afterDeleteMany =
|
|
225
|
+
// export const afterDeleteMany =
|
|
258
226
|
// async (${functionParams}) => {
|
|
259
227
|
// // Your logic here
|
|
260
228
|
// next();
|
|
261
229
|
// }
|
|
262
|
-
// );
|
|
263
230
|
`;
|
|
264
231
|
}
|
|
265
232
|
//# sourceMappingURL=generate-middlewares.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-middlewares.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/generate-middlewares.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAGtE,MAAM,UAAU,2BAA2B,CAAC,OAAwB;IAClE,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC9B,MAAM,GAAG,GAAG,oBAAoB,EAAE,CAAC;IACnC,MAAM,YAAY,GAAG,GAAG,KAAK,IAAI,CAAC;IAElC,IAAI,CAAC,SAAS;QACZ,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;IAEpE,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,KAAK,MAAM,CAAC;IAC1C,MAAM,YAAY,GAChB,SAAS,CAAC,KAAK,KAAK,YAAY,IAAI,SAAS,CAAC,KAAK,KAAK,aAAa,CAAC;IAGxE,MAAM,WAAW,GAAG,YAAY,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC;IAC1D,MAAM,YAAY,GAAG,YAAY,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,KAAK,CAAC;IAC5D,MAAM,QAAQ,GAAG,YAAY,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,MAAM,CAAC;IAE7D,MAAM,WAAW,GAAG,YAAY;QAC9B,CAAC,CAAC;kDAC4C;QAC9C,CAAC,CAAC,mDAAmD,CAAC;IAExD,MAAM,cAAc,GAAG,YAAY;QACjC,CAAC,CAAC,QAAQ,WAAW,UAAU,YAAY,WAAW,QAAQ,EAAE;QAChE,CAAC,CAAC,gBAAgB,CAAC;IAErB,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,GAAG,WAAW;;;cAGX,cAAc
|
|
1
|
+
{"version":3,"file":"generate-middlewares.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/generate-middlewares.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAGtE,MAAM,UAAU,2BAA2B,CAAC,OAAwB;IAClE,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC9B,MAAM,GAAG,GAAG,oBAAoB,EAAE,CAAC;IACnC,MAAM,YAAY,GAAG,GAAG,KAAK,IAAI,CAAC;IAElC,IAAI,CAAC,SAAS;QACZ,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;IAEpE,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,KAAK,MAAM,CAAC;IAC1C,MAAM,YAAY,GAChB,SAAS,CAAC,KAAK,KAAK,YAAY,IAAI,SAAS,CAAC,KAAK,KAAK,aAAa,CAAC;IAGxE,MAAM,WAAW,GAAG,YAAY,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC;IAC1D,MAAM,YAAY,GAAG,YAAY,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,KAAK,CAAC;IAC5D,MAAM,QAAQ,GAAG,YAAY,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,MAAM,CAAC;IAE7D,MAAM,WAAW,GAAG,YAAY;QAC9B,CAAC,CAAC;kDAC4C;QAC9C,CAAC,CAAC,mDAAmD,CAAC;IAExD,MAAM,cAAc,GAAG,YAAY;QACjC,CAAC,CAAC,QAAQ,WAAW,UAAU,YAAY,WAAW,QAAQ,EAAE;QAChE,CAAC,CAAC,gBAAgB,CAAC;IAErB,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,GAAG,WAAW;;;cAGX,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;CAI3B,CAAC;IACA,CAAC;IAED,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,GAAG,WAAW;;;;cAIX,cAAc;;;;;;;;cAQd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;CAI3B,CAAC;IACA,CAAC;IAGD,OAAO,GAAG,WAAW;;;cAGT,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;;;cAMd,cAAc;;;;CAI3B,CAAC;AACF,CAAC","sourcesContent":["import { getUserFileExtension } from \"../../../../helpers/fs.helpers\";\nimport { TemplateOptions } from \"../../template-generators\";\n\nexport function generateMiddlewaresTemplate(options: TemplateOptions): string {\n const { modelName } = options;\n const ext = getUserFileExtension();\n const isTypeScript = ext === \"ts\";\n\n if (!modelName)\n throw new Error(\"Model name is required for middleware template\");\n\n const isAuth = modelName.camel === \"auth\";\n const isFileUpload =\n modelName.camel === \"fileUpload\" || modelName.camel === \"file-upload\";\n\n // Generate imports based on TypeScript/JavaScript\n const requestType = isTypeScript ? \"ArkosRequest\" : \"req\";\n const responseType = isTypeScript ? \"ArkosResponse\" : \"res\";\n const nextType = isTypeScript ? \"ArkosNextFunction\" : \"next\";\n\n const baseImports = isTypeScript\n ? `import { ArkosRequest, ArkosResponse, ArkosNextFunction } from \"arkos\";\nimport { catchAsync } from \"arkos/error-handler\";`\n : `import { catchAsync } from \"arkos/error-handler\";`;\n\n const functionParams = isTypeScript\n ? `req: ${requestType}, res: ${responseType}, next: ${nextType}`\n : `req, res, next`;\n\n if (isAuth) {\n return `${baseImports}\n\n// export const beforeGetMe = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const afterGetMe = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const beforeLogin = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const afterLogin = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const beforeLogout = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const afterLogout = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const beforeSignup = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const afterSignup = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const beforeUpdatePassword = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const afterUpdatePassword = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n`;\n }\n\n if (isFileUpload) {\n return `${baseImports}\n\n\n// export const beforeFindFile = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// There is not afterFindFile: because the main handler is handleded by express.static()\n\n// export const beforeUploadFile = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const afterUploadFile = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const beforeUpdateFile = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const afterUpdateFile = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const beforeDeleteFile = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const afterDeleteFile = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n`;\n }\n\n // Regular model middlewares\n return `${baseImports}\n\n// export const beforeCreateOne = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const afterCreateOne = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const beforeFindOne = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const afterFindOne = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const beforeFindMany = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const afterFindMany = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const beforeUpdateOne = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const afterUpdateOne = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const beforeDeleteOne = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const afterDeleteOne = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const beforeCreateMany = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const afterCreateMany = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const beforeUpdateMany = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const afterUpdateMany = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const beforeDeleteMany = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n\n// export const afterDeleteMany = \n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n`;\n}\n"]}
|
package/dist/esm/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getUserFileExtension } from "../../../../helpers/fs.helpers
|
|
1
|
+
import { getUserFileExtension } from "../../../../helpers/fs.helpers";
|
|
2
2
|
export function generateQueryOptionsTemplate(options) {
|
|
3
3
|
const { modelName } = options;
|
|
4
4
|
const isAuth = modelName?.camel === "auth";
|
|
@@ -15,7 +15,7 @@ export function generateQueryOptionsTemplate(options) {
|
|
|
15
15
|
: `: PrismaQueryOptions<typeof prisma.${modelName.camel}>`
|
|
16
16
|
: "";
|
|
17
17
|
const prismaImport = isTypeScript
|
|
18
|
-
? `import { prisma } from "../../utils/prisma
|
|
18
|
+
? `import { prisma } from "../../utils/prisma";\n`
|
|
19
19
|
: "";
|
|
20
20
|
if (isAuth) {
|
|
21
21
|
return `${prismaImport}${imports};
|
|
@@ -36,16 +36,22 @@ export default ${modelName.camel}QueryOptions;
|
|
|
36
36
|
return `${prismaImport}${imports};
|
|
37
37
|
|
|
38
38
|
const ${modelName.camel}QueryOptions${typeAnnotation} = {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
39
|
+
global: {},
|
|
40
|
+
find: {},
|
|
41
|
+
findOne: {},
|
|
42
|
+
findMany: {},
|
|
43
|
+
udpate: {},
|
|
44
|
+
updateMany: {},
|
|
45
|
+
updateOne: {},
|
|
46
|
+
create: {},
|
|
47
|
+
createMany: {},
|
|
48
|
+
createOne: {},
|
|
49
|
+
save: {},
|
|
50
|
+
saveMany: {},
|
|
51
|
+
saveOne: {},
|
|
52
|
+
delete: {},
|
|
53
|
+
deleteMany: {},
|
|
54
|
+
deleteOne: {},
|
|
49
55
|
}
|
|
50
56
|
|
|
51
57
|
export default ${modelName.camel}QueryOptions;
|
package/dist/esm/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-prisma-query-options.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/generate-prisma-query-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAGtE,MAAM,UAAU,4BAA4B,CAAC,OAAwB;IACnE,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC9B,MAAM,MAAM,GAAG,SAAS,EAAE,KAAK,KAAK,MAAM,CAAC;IAC3C,MAAM,GAAG,GAAG,oBAAoB,EAAE,CAAC;IACnC,MAAM,YAAY,GAAG,GAAG,KAAK,IAAI,CAAC;IAElC,IAAI,CAAC,SAAS;QACZ,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;IAGtE,MAAM,OAAO,GAAG,MAAM;QACpB,CAAC,CAAC,uDAAuD;QACzD,CAAC,CAAC,mDAAmD,CAAC;IAGxD,MAAM,cAAc,GAAG,YAAY;QACjC,CAAC,CAAC,MAAM;YACN,CAAC,CAAC,0CAA0C,SAAS,CAAC,KAAK,GAAG;YAC9D,CAAC,CAAC,sCAAsC,SAAS,CAAC,KAAK,GAAG;QAC5D,CAAC,CAAC,EAAE,CAAC;IAGP,MAAM,YAAY,GAAG,YAAY;QAC/B,CAAC,CAAC,gDAAgD;QAClD,CAAC,CAAC,EAAE,CAAC;IAEP,IAAI,MAAM,EAAE,CAAC;QAEX,OAAO,GAAG,YAAY,GAAG,OAAO;;QAE5B,SAAS,CAAC,KAAK,eAAe,cAAc;;;;;;;;;iBASnC,SAAS,CAAC,KAAK;CAC/B,CAAC;IACA,CAAC;SAAM,CAAC;QAEN,OAAO,GAAG,YAAY,GAAG,OAAO;;QAE5B,SAAS,CAAC,KAAK,eAAe,cAAc
|
|
1
|
+
{"version":3,"file":"generate-prisma-query-options.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/generate-prisma-query-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAGtE,MAAM,UAAU,4BAA4B,CAAC,OAAwB;IACnE,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC9B,MAAM,MAAM,GAAG,SAAS,EAAE,KAAK,KAAK,MAAM,CAAC;IAC3C,MAAM,GAAG,GAAG,oBAAoB,EAAE,CAAC;IACnC,MAAM,YAAY,GAAG,GAAG,KAAK,IAAI,CAAC;IAElC,IAAI,CAAC,SAAS;QACZ,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;IAGtE,MAAM,OAAO,GAAG,MAAM;QACpB,CAAC,CAAC,uDAAuD;QACzD,CAAC,CAAC,mDAAmD,CAAC;IAGxD,MAAM,cAAc,GAAG,YAAY;QACjC,CAAC,CAAC,MAAM;YACN,CAAC,CAAC,0CAA0C,SAAS,CAAC,KAAK,GAAG;YAC9D,CAAC,CAAC,sCAAsC,SAAS,CAAC,KAAK,GAAG;QAC5D,CAAC,CAAC,EAAE,CAAC;IAGP,MAAM,YAAY,GAAG,YAAY;QAC/B,CAAC,CAAC,gDAAgD;QAClD,CAAC,CAAC,EAAE,CAAC;IAEP,IAAI,MAAM,EAAE,CAAC;QAEX,OAAO,GAAG,YAAY,GAAG,OAAO;;QAE5B,SAAS,CAAC,KAAK,eAAe,cAAc;;;;;;;;;iBASnC,SAAS,CAAC,KAAK;CAC/B,CAAC;IACA,CAAC;SAAM,CAAC;QAEN,OAAO,GAAG,YAAY,GAAG,OAAO;;QAE5B,SAAS,CAAC,KAAK,eAAe,cAAc;;;;;;;;;;;;;;;;;;;iBAmBnC,SAAS,CAAC,KAAK;CAC/B,CAAC;IACA,CAAC;AACH,CAAC","sourcesContent":["import { getUserFileExtension } from \"../../../../helpers/fs.helpers\";\nimport { TemplateOptions } from \"../../template-generators\";\n\nexport function generateQueryOptionsTemplate(options: TemplateOptions): string {\n const { modelName } = options;\n const isAuth = modelName?.camel === \"auth\";\n const ext = getUserFileExtension();\n const isTypeScript = ext === \"ts\";\n\n if (!modelName)\n throw new Error(\"Model name is required for query config template\");\n\n // Generate imports\n const imports = isAuth\n ? `import { AuthPrismaQueryOptions } from 'arkos/prisma'`\n : `import { PrismaQueryOptions } from 'arkos/prisma'`;\n\n // Generate type annotation for TypeScript\n const typeAnnotation = isTypeScript\n ? isAuth\n ? `: AuthPrismaQueryOptions<typeof prisma.${modelName.camel}>`\n : `: PrismaQueryOptions<typeof prisma.${modelName.camel}>`\n : \"\";\n\n // Generate prisma import if TypeScript\n const prismaImport = isTypeScript\n ? `import { prisma } from \"../../utils/prisma\";\\n`\n : \"\";\n\n if (isAuth) {\n // Auth template\n return `${prismaImport}${imports};\n\nconst ${modelName.camel}QueryOptions${typeAnnotation} = {\n getMe: {},\n updateMe: {},\n deleteMe: {},\n login: {},\n signup: {},\n updatePassword: {},\n}\n\nexport default ${modelName.camel}QueryOptions;\n`;\n } else {\n // Regular template\n return `${prismaImport}${imports};\n\nconst ${modelName.camel}QueryOptions${typeAnnotation} = {\n global: {},\n find: {},\n findOne: {},\n findMany: {},\n udpate: {},\n updateMany: {},\n updateOne: {},\n create: {},\n createMany: {},\n createOne: {},\n save: {},\n saveMany: {},\n saveOne: {},\n delete: {},\n deleteMany: {},\n deleteOne: {},\n}\n\nexport default ${modelName.camel}QueryOptions;\n`;\n }\n}\n"]}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import pluralize from "pluralize";
|
|
2
|
-
import { checkFileExists, getUserFileExtension, } from "../../../../helpers/fs.helpers
|
|
2
|
+
import { checkFileExists, getUserFileExtension, } from "../../../../helpers/fs.helpers";
|
|
3
3
|
export function generateRouterTemplate(options) {
|
|
4
4
|
const { modelName, imports } = options;
|
|
5
5
|
if (!modelName)
|
|
6
6
|
throw new Error("Model name is required for router template");
|
|
7
7
|
const ext = getUserFileExtension();
|
|
8
8
|
const controllerPath = imports?.controller || `./${modelName.kebab}.controller.${ext}`;
|
|
9
|
+
const routerConfigTsType = ext === "ts" ? ": RouterConfig" : "";
|
|
10
|
+
const routerConfigTsTypeImport = ext === "ts" ? "import { RouterConfig } from 'arkos'" : "";
|
|
9
11
|
const controllerExists = checkFileExists(controllerPath);
|
|
10
12
|
const controllerImportLine = controllerExists
|
|
11
13
|
? `import ${modelName.camel}Controller from "${imports?.controller || `./${modelName.kebab}.controller`}"`
|
|
@@ -16,6 +18,9 @@ export function generateRouterTemplate(options) {
|
|
|
16
18
|
return `import { Router } from 'express'
|
|
17
19
|
import { authService } from 'arkos/services'
|
|
18
20
|
${controllerImportLine}
|
|
21
|
+
${routerConfigTsTypeImport}
|
|
22
|
+
|
|
23
|
+
export const config${routerConfigTsType} = { }
|
|
19
24
|
|
|
20
25
|
const ${modelName.camel}Router = Router()
|
|
21
26
|
|
package/dist/esm/utils/cli/utils/template-generator/templates/generate-router-template.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-router-template.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/generate-router-template.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EACL,eAAe,EACf,oBAAoB,GACrB,MAAM,gCAAgC,CAAC;AAGxC,MAAM,UAAU,sBAAsB,CAAC,OAAwB;IAC7D,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAEvC,IAAI,CAAC,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAG9E,MAAM,GAAG,GAAG,oBAAoB,EAAE,CAAC;IACnC,MAAM,cAAc,GAClB,OAAO,EAAE,UAAU,IAAI,KAAK,SAAS,CAAC,KAAK,eAAe,GAAG,EAAE,CAAC;IAElE,MAAM,gBAAgB,GAAG,eAAe,CAAC,cAAc,CAAC,CAAC;IAEzD,MAAM,oBAAoB,GAAG,gBAAgB;QAC3C,CAAC,CAAC,UAAU,SAAS,CAAC,KAAK,oBACvB,OAAO,EAAE,UAAU,IAAI,KAAK,SAAS,CAAC,KAAK,aAC7C,GAAG;QACL,CAAC,CAAC,aAAa,SAAS,CAAC,KAAK,oBAC1B,OAAO,EAAE,UAAU,IAAI,KAAK,SAAS,CAAC,KAAK,aAC7C,GAAG,CAAC;IAER,MAAM,qBAAqB,GAAG,gBAAgB;QAC5C,CAAC,CAAC,KAAK,SAAS,CAAC,KAAK,wBAAwB;QAC9C,CAAC,CAAC,QAAQ,SAAS,CAAC,KAAK,wBAAwB,CAAC;IAEpD,OAAO;;EAEP,oBAAoB;;
|
|
1
|
+
{"version":3,"file":"generate-router-template.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/generate-router-template.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EACL,eAAe,EACf,oBAAoB,GACrB,MAAM,gCAAgC,CAAC;AAGxC,MAAM,UAAU,sBAAsB,CAAC,OAAwB;IAC7D,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAEvC,IAAI,CAAC,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAG9E,MAAM,GAAG,GAAG,oBAAoB,EAAE,CAAC;IACnC,MAAM,cAAc,GAClB,OAAO,EAAE,UAAU,IAAI,KAAK,SAAS,CAAC,KAAK,eAAe,GAAG,EAAE,CAAC;IAElE,MAAM,kBAAkB,GAAG,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC;IAChE,MAAM,wBAAwB,GAC5B,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,sCAAsC,CAAC,CAAC,CAAC,EAAE,CAAC;IAE7D,MAAM,gBAAgB,GAAG,eAAe,CAAC,cAAc,CAAC,CAAC;IAEzD,MAAM,oBAAoB,GAAG,gBAAgB;QAC3C,CAAC,CAAC,UAAU,SAAS,CAAC,KAAK,oBACvB,OAAO,EAAE,UAAU,IAAI,KAAK,SAAS,CAAC,KAAK,aAC7C,GAAG;QACL,CAAC,CAAC,aAAa,SAAS,CAAC,KAAK,oBAC1B,OAAO,EAAE,UAAU,IAAI,KAAK,SAAS,CAAC,KAAK,aAC7C,GAAG,CAAC;IAER,MAAM,qBAAqB,GAAG,gBAAgB;QAC5C,CAAC,CAAC,KAAK,SAAS,CAAC,KAAK,wBAAwB;QAC9C,CAAC,CAAC,QAAQ,SAAS,CAAC,KAAK,wBAAwB,CAAC;IAEpD,OAAO;;EAEP,oBAAoB;EACpB,wBAAwB;;qBAEL,kBAAkB;;QAE/B,SAAS,CAAC,KAAK;;EAErB,SAAS,CAAC,KAAK;4CAC2B,SAAS,CACjD,SAAS,CAAC,KAAK,CAChB;;qDAEkD,SAAS,CAAC,KAAK;EAClE,qBAAqB;;;iBAGN,SAAS,CAAC,KAAK;CAC/B,CAAC;AACF,CAAC","sourcesContent":["import pluralize from \"pluralize\";\nimport {\n checkFileExists,\n getUserFileExtension,\n} from \"../../../../helpers/fs.helpers\";\nimport { TemplateOptions } from \"../../template-generators\";\n\nexport function generateRouterTemplate(options: TemplateOptions): string {\n const { modelName, imports } = options;\n\n if (!modelName) throw new Error(\"Model name is required for router template\");\n\n // Check if controller file exists\n const ext = getUserFileExtension();\n const controllerPath =\n imports?.controller || `./${modelName.kebab}.controller.${ext}`;\n\n const routerConfigTsType = ext === \"ts\" ? \": RouterConfig\" : \"\";\n const routerConfigTsTypeImport =\n ext === \"ts\" ? \"import { RouterConfig } from 'arkos'\" : \"\";\n\n const controllerExists = checkFileExists(controllerPath);\n\n const controllerImportLine = controllerExists\n ? `import ${modelName.camel}Controller from \"${\n imports?.controller || `./${modelName.kebab}.controller`\n }\"`\n : `// import ${modelName.camel}Controller from \"${\n imports?.controller || `./${modelName.kebab}.controller`\n }\"`;\n\n const controllerHandlerLine = controllerExists\n ? ` ${modelName.camel}Controller.someHandler`\n : ` // ${modelName.camel}Controller.someHandler`;\n\n return `import { Router } from 'express'\nimport { authService } from 'arkos/services'\n${controllerImportLine}\n${routerConfigTsTypeImport}\n\nexport const config${routerConfigTsType} = { }\n\nconst ${modelName.camel}Router = Router()\n\n${modelName.camel}Router.post(\n '/custom-endpoint', // resolves to /api/${pluralize(\n modelName.kebab\n )}/custom-endpoint\n authService.authenticate,\n authService.handleAccessControl('CustomAction', '${modelName.kebab}'),\n${controllerHandlerLine}\n)\n\nexport default ${modelName.camel}Router\n`;\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getUserFileExtension } from "../../../../helpers/fs.helpers
|
|
1
|
+
import { getUserFileExtension } from "../../../../helpers/fs.helpers";
|
|
2
2
|
export function generateServiceTemplate(options) {
|
|
3
3
|
const { modelName, imports } = options;
|
|
4
4
|
const ext = getUserFileExtension();
|
|
@@ -6,7 +6,7 @@ export function generateServiceTemplate(options) {
|
|
|
6
6
|
if (!modelName)
|
|
7
7
|
throw new Error("Model name is required for service template");
|
|
8
8
|
const prismaImport = isTypeScript
|
|
9
|
-
? `import { prisma } from "../../utils/prisma
|
|
9
|
+
? `import { prisma } from "../../utils/prisma";\n`
|
|
10
10
|
: "";
|
|
11
11
|
const baseServiceImport = isTypeScript
|
|
12
12
|
? `import { BaseService } from "${imports?.baseService || "arkos/services"}";`
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { generateControllerTemplate } from "./template-generator/templates/generate-controller-template
|
|
2
|
-
import { generateAuthConfigsTemplate } from "./template-generator/templates/generate-auth-configs-template
|
|
3
|
-
import { generateMiddlewaresTemplate } from "./template-generator/templates/generate-middlewares
|
|
4
|
-
import { generateQueryOptionsTemplate } from "./template-generator/templates/generate-prisma-query-options
|
|
5
|
-
import { generateRouterTemplate } from "./template-generator/templates/generate-router-template
|
|
6
|
-
import { generateServiceTemplate } from "./template-generator/templates/generate-service-template
|
|
1
|
+
import { generateControllerTemplate } from "./template-generator/templates/generate-controller-template";
|
|
2
|
+
import { generateAuthConfigsTemplate } from "./template-generator/templates/generate-auth-configs-template";
|
|
3
|
+
import { generateMiddlewaresTemplate } from "./template-generator/templates/generate-middlewares";
|
|
4
|
+
import { generateQueryOptionsTemplate } from "./template-generator/templates/generate-prisma-query-options";
|
|
5
|
+
import { generateRouterTemplate } from "./template-generator/templates/generate-router-template";
|
|
6
|
+
import { generateServiceTemplate } from "./template-generator/templates/generate-service-template";
|
|
7
7
|
export function generateTemplate(type, options) {
|
|
8
8
|
switch (type) {
|
|
9
9
|
case "controller":
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import deepmerge from "../helpers/deepmerge.helper
|
|
2
|
-
import { parseQueryParamsWithModifiers } from "../helpers/api.features.helpers
|
|
3
|
-
import AppError from "../../modules/error-handler/utils/app-error
|
|
4
|
-
import { getPrismaInstance } from "../helpers/prisma.helpers
|
|
1
|
+
import deepmerge from "../helpers/deepmerge.helper";
|
|
2
|
+
import { parseQueryParamsWithModifiers } from "../helpers/api.features.helpers";
|
|
3
|
+
import AppError from "../../modules/error-handler/utils/app-error";
|
|
4
|
+
import { getPrismaInstance } from "../helpers/prisma.helpers";
|
|
5
5
|
export default class APIFeatures {
|
|
6
6
|
constructor(req, modelName) {
|
|
7
7
|
this.filters = {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as changeCase from "../helpers/change-case.helpers
|
|
1
|
+
import * as changeCase from "../helpers/change-case.helpers";
|
|
2
2
|
const isObject = (object) => object !== null && typeof object === "object";
|
|
3
3
|
function changeKeysFactory(changeCase) {
|
|
4
4
|
return function changeKeys(object, depth = 1, options) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import fs from "fs";
|
|
3
|
-
import { camelCase, kebabCase, pascalCase, } from "../../utils/helpers/change-case.helpers
|
|
4
|
-
import { crd, getUserFileExtension } from "./fs.helpers
|
|
5
|
-
import { importModule } from "./global.helpers
|
|
6
|
-
import { killServerChildProcess } from "../cli/utils/cli.helpers
|
|
3
|
+
import { camelCase, kebabCase, pascalCase, } from "../../utils/helpers/change-case.helpers";
|
|
4
|
+
import { crd, getUserFileExtension } from "./fs.helpers";
|
|
5
|
+
import { importModule } from "./global.helpers";
|
|
6
|
+
import { killServerChildProcess } from "../cli/utils/cli.helpers";
|
|
7
7
|
let prismaModelsModules = {};
|
|
8
8
|
export function getModelModules(modelName) {
|
|
9
9
|
return prismaModelsModules[kebabCase(modelName)];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
|
-
import catchAsync from "../../modules/error-handler/utils/catch-async
|
|
3
|
-
import AppError from "../../modules/error-handler/utils/app-error
|
|
4
|
-
import { crd, getUserFileExtension as ext } from "./fs.helpers
|
|
5
|
-
import { importModule } from "./global.helpers
|
|
2
|
+
import catchAsync from "../../modules/error-handler/utils/catch-async";
|
|
3
|
+
import AppError from "../../modules/error-handler/utils/app-error";
|
|
4
|
+
import { crd, getUserFileExtension as ext } from "./fs.helpers";
|
|
5
|
+
import { importModule } from "./global.helpers";
|
|
6
6
|
export let prismaInstance = null;
|
|
7
7
|
export async function loadPrismaModule() {
|
|
8
8
|
if (!prismaInstance) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { plainToInstance } from "class-transformer";
|
|
2
2
|
import { validate } from "class-validator";
|
|
3
|
-
import AppError from "../modules/error-handler/utils/app-error
|
|
3
|
+
import AppError from "../modules/error-handler/utils/app-error";
|
|
4
4
|
export default async function validateDto(DtoClass, data, validationOptions) {
|
|
5
5
|
const dataDto = plainToInstance(DtoClass, data);
|
|
6
6
|
const errors = await validate(dataDto, validationOptions);
|