arkos 1.2.16-test → 1.2.19-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.
Files changed (88) hide show
  1. package/dist/cjs/app.js +1 -1
  2. package/dist/cjs/modules/auth/auth.service.js +0 -7
  3. package/dist/cjs/modules/auth/auth.service.js.map +1 -1
  4. package/dist/cjs/paths.js +1 -1
  5. package/dist/cjs/server.js +2 -2
  6. package/dist/cjs/server.js.map +1 -1
  7. package/dist/cjs/utils/cli/build.js +2 -2
  8. package/dist/cjs/utils/cli/build.js.map +1 -1
  9. package/dist/cjs/utils/cli/dev.js +4 -2
  10. package/dist/cjs/utils/cli/dev.js.map +1 -1
  11. package/dist/cjs/utils/cli/utils/template-generator/templates/generate-middlewares.js +33 -66
  12. package/dist/cjs/utils/cli/utils/template-generator/templates/generate-middlewares.js.map +1 -1
  13. package/dist/cjs/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js +16 -10
  14. package/dist/cjs/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js.map +1 -1
  15. package/dist/cjs/utils/cli/utils/template-generator/templates/generate-router-template.js +5 -0
  16. package/dist/cjs/utils/cli/utils/template-generator/templates/generate-router-template.js.map +1 -1
  17. package/dist/cjs/utils/helpers/global.helpers.js +21 -0
  18. package/dist/cjs/utils/helpers/global.helpers.js.map +1 -1
  19. package/dist/cjs/utils/helpers/models.helpers.js +0 -1
  20. package/dist/cjs/utils/helpers/models.helpers.js.map +1 -1
  21. package/dist/esm/app.js +1 -1
  22. package/dist/esm/exports/auth/index.js +1 -1
  23. package/dist/esm/exports/controllers/index.js +2 -2
  24. package/dist/esm/exports/error-handler/index.js +2 -2
  25. package/dist/esm/exports/index.js +2 -2
  26. package/dist/esm/exports/middlewares/index.js +1 -1
  27. package/dist/esm/exports/prisma/index.js +1 -1
  28. package/dist/esm/exports/services/index.js +4 -4
  29. package/dist/esm/exports/utils/index.js +2 -2
  30. package/dist/esm/exports/validation/index.js +2 -2
  31. package/dist/esm/modules/auth/auth.controller.js +7 -7
  32. package/dist/esm/modules/auth/auth.router.js +6 -6
  33. package/dist/esm/modules/auth/auth.service.js +6 -13
  34. package/dist/esm/modules/auth/auth.service.js.map +1 -1
  35. package/dist/esm/modules/auth/utils/helpers/auth.controller.helpers.js +2 -2
  36. package/dist/esm/modules/base/base.controller.js +7 -7
  37. package/dist/esm/modules/base/base.middlewares.js +6 -6
  38. package/dist/esm/modules/base/base.router.js +4 -4
  39. package/dist/esm/modules/base/base.service.js +6 -6
  40. package/dist/esm/modules/base/utils/helpers/base.controller.helpers.js +1 -1
  41. package/dist/esm/modules/base/utils/helpers/base.middlewares.helpers.js +1 -1
  42. package/dist/esm/modules/base/utils/helpers/base.router.helpers.js +6 -6
  43. package/dist/esm/modules/base/utils/helpers/base.service.helpers.js +1 -1
  44. package/dist/esm/modules/email/email.service.js +2 -2
  45. package/dist/esm/modules/error-handler/error-handler.controller.js +3 -3
  46. package/dist/esm/modules/error-handler/utils/error-handler.helpers.js +1 -1
  47. package/dist/esm/modules/file-upload/file-upload.controller.js +7 -7
  48. package/dist/esm/modules/file-upload/file-upload.router.js +5 -5
  49. package/dist/esm/modules/file-upload/file-upload.service.js +5 -5
  50. package/dist/esm/modules/file-upload/utils/helpers/file-upload.helpers.js +2 -2
  51. package/dist/esm/modules/swagger/swagger.router.js +2 -2
  52. package/dist/esm/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js +2 -2
  53. package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js +3 -3
  54. package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.js +2 -2
  55. package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schema.js +2 -2
  56. package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes.js +2 -2
  57. package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes.js +3 -3
  58. package/dist/esm/modules/swagger/utils/helpers/swagger.router.helpers.js +9 -9
  59. package/dist/esm/server.js +2 -2
  60. package/dist/esm/server.js.map +1 -1
  61. package/dist/esm/utils/cli/build.js +4 -4
  62. package/dist/esm/utils/cli/build.js.map +1 -1
  63. package/dist/esm/utils/cli/dev.js +9 -7
  64. package/dist/esm/utils/cli/dev.js.map +1 -1
  65. package/dist/esm/utils/cli/generate.js +4 -4
  66. package/dist/esm/utils/cli/index.js +5 -5
  67. package/dist/esm/utils/cli/start.js +4 -4
  68. package/dist/esm/utils/cli/utils/cli.helpers.js +2 -2
  69. package/dist/esm/utils/cli/utils/template-generator/templates/generate-auth-configs-template.js +1 -1
  70. package/dist/esm/utils/cli/utils/template-generator/templates/generate-middlewares.js +34 -67
  71. package/dist/esm/utils/cli/utils/template-generator/templates/generate-middlewares.js.map +1 -1
  72. package/dist/esm/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js +18 -12
  73. package/dist/esm/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js.map +1 -1
  74. package/dist/esm/utils/cli/utils/template-generator/templates/generate-router-template.js +6 -1
  75. package/dist/esm/utils/cli/utils/template-generator/templates/generate-router-template.js.map +1 -1
  76. package/dist/esm/utils/cli/utils/template-generator/templates/generate-service-template.js +2 -2
  77. package/dist/esm/utils/cli/utils/template-generators.js +6 -6
  78. package/dist/esm/utils/features/api.features.js +4 -4
  79. package/dist/esm/utils/features/change-case.features.js +1 -1
  80. package/dist/esm/utils/helpers/global.helpers.js +20 -0
  81. package/dist/esm/utils/helpers/global.helpers.js.map +1 -1
  82. package/dist/esm/utils/helpers/models.helpers.js +4 -5
  83. package/dist/esm/utils/helpers/models.helpers.js.map +1 -1
  84. package/dist/esm/utils/helpers/prisma.helpers.js +4 -4
  85. package/dist/esm/utils/validate-dto.js +1 -1
  86. package/dist/esm/utils/validate-schema.js +1 -1
  87. package/dist/types/utils/helpers/global.helpers.d.ts +1 -0
  88. package/package.json +2 -4
@@ -23,246 +23,213 @@ import { catchAsync } from "arkos/error-handler";`
23
23
  if (isAuth) {
24
24
  return `${baseImports}
25
25
 
26
- // export const beforeGetMe = catchAsync(
26
+ // export const beforeGetMe =
27
27
  // async (${functionParams}) => {
28
28
  // // Your logic here
29
29
  // next();
30
30
  // }
31
- // );
32
31
 
33
- // export const afterGetMe = catchAsync(
32
+ // export const afterGetMe =
34
33
  // async (${functionParams}) => {
35
34
  // // Your logic here
36
35
  // next();
37
36
  // }
38
- // );
39
37
 
40
- // export const beforeLogin = catchAsync(
38
+ // export const beforeLogin =
41
39
  // async (${functionParams}) => {
42
40
  // // Your logic here
43
41
  // next();
44
42
  // }
45
- // );
46
43
 
47
- // export const afterLogin = catchAsync(
44
+ // export const afterLogin =
48
45
  // async (${functionParams}) => {
49
46
  // // Your logic here
50
47
  // next();
51
48
  // }
52
- // );
53
49
 
54
- // export const beforeLogout = catchAsync(
50
+ // export const beforeLogout =
55
51
  // async (${functionParams}) => {
56
52
  // // Your logic here
57
53
  // next();
58
54
  // }
59
- // );
60
55
 
61
- // export const afterLogout = catchAsync(
56
+ // export const afterLogout =
62
57
  // async (${functionParams}) => {
63
58
  // // Your logic here
64
59
  // next();
65
60
  // }
66
- // );
67
61
 
68
- // export const beforeSignup = catchAsync(
62
+ // export const beforeSignup =
69
63
  // async (${functionParams}) => {
70
64
  // // Your logic here
71
65
  // next();
72
66
  // }
73
- // );
74
67
 
75
- // export const afterSignup = catchAsync(
68
+ // export const afterSignup =
76
69
  // async (${functionParams}) => {
77
70
  // // Your logic here
78
71
  // next();
79
72
  // }
80
- // );
81
73
 
82
- // export const beforeUpdatePassword = catchAsync(
74
+ // export const beforeUpdatePassword =
83
75
  // async (${functionParams}) => {
84
76
  // // Your logic here
85
77
  // next();
86
78
  // }
87
- // );
88
79
 
89
- // export const afterUpdatePassword = catchAsync(
80
+ // export const afterUpdatePassword =
90
81
  // async (${functionParams}) => {
91
82
  // // Your logic here
92
83
  // next();
93
84
  // }
94
- // );
95
85
  `;
96
86
  }
97
87
  if (isFileUpload) {
98
88
  return `${baseImports}
99
89
 
100
90
 
101
- // export const beforeFindFile = catchAsync(
91
+ // export const beforeFindFile =
102
92
  // async (${functionParams}) => {
103
93
  // // Your logic here
104
94
  // next();
105
95
  // }
106
- // );
107
96
 
108
97
  // There is not afterFindFile: because the main handler is handleded by express.static()
109
98
 
110
- // export const beforeUploadFile = catchAsync(
99
+ // export const beforeUploadFile =
111
100
  // async (${functionParams}) => {
112
101
  // // Your logic here
113
102
  // next();
114
103
  // }
115
- // );
116
104
 
117
- // export const afterUploadFile = catchAsync(
105
+ // export const afterUploadFile =
118
106
  // async (${functionParams}) => {
119
107
  // // Your logic here
120
108
  // next();
121
109
  // }
122
- // );
123
110
 
124
- // export const beforeUpdateFile = catchAsync(
111
+ // export const beforeUpdateFile =
125
112
  // async (${functionParams}) => {
126
113
  // // Your logic here
127
114
  // next();
128
115
  // }
129
- // );
130
116
 
131
- // export const afterUpdateFile = catchAsync(
117
+ // export const afterUpdateFile =
132
118
  // async (${functionParams}) => {
133
119
  // // Your logic here
134
120
  // next();
135
121
  // }
136
- // );
137
122
 
138
- // export const beforeDeleteFile = catchAsync(
123
+ // export const beforeDeleteFile =
139
124
  // async (${functionParams}) => {
140
125
  // // Your logic here
141
126
  // next();
142
127
  // }
143
- // );
144
128
 
145
- // export const afterDeleteFile = catchAsync(
129
+ // export const afterDeleteFile =
146
130
  // async (${functionParams}) => {
147
131
  // // Your logic here
148
132
  // next();
149
133
  // }
150
- // );
151
134
  `;
152
135
  }
153
136
  return `${baseImports}
154
137
 
155
- // export const beforeCreateOne = catchAsync(
138
+ // export const beforeCreateOne =
156
139
  // async (${functionParams}) => {
157
140
  // // Your logic here
158
141
  // next();
159
142
  // }
160
- // );
161
143
 
162
- // export const afterCreateOne = catchAsync(
144
+ // export const afterCreateOne =
163
145
  // async (${functionParams}) => {
164
146
  // // Your logic here
165
147
  // next();
166
148
  // }
167
- // );
168
149
 
169
- // export const beforeFindOne = catchAsync(
150
+ // export const beforeFindOne =
170
151
  // async (${functionParams}) => {
171
152
  // // Your logic here
172
153
  // next();
173
154
  // }
174
- // );
175
155
 
176
- // export const afterFindOne = catchAsync(
156
+ // export const afterFindOne =
177
157
  // async (${functionParams}) => {
178
158
  // // Your logic here
179
159
  // next();
180
160
  // }
181
- // );
182
161
 
183
- // export const beforeFindMany = catchAsync(
162
+ // export const beforeFindMany =
184
163
  // async (${functionParams}) => {
185
164
  // // Your logic here
186
165
  // next();
187
166
  // }
188
- // );
189
167
 
190
- // export const afterFindMany = catchAsync(
168
+ // export const afterFindMany =
191
169
  // async (${functionParams}) => {
192
170
  // // Your logic here
193
171
  // next();
194
172
  // }
195
- // );
196
173
 
197
- // export const beforeUpdateOne = catchAsync(
174
+ // export const beforeUpdateOne =
198
175
  // async (${functionParams}) => {
199
176
  // // Your logic here
200
177
  // next();
201
178
  // }
202
- // );
203
179
 
204
- // export const afterUpdateOne = catchAsync(
180
+ // export const afterUpdateOne =
205
181
  // async (${functionParams}) => {
206
182
  // // Your logic here
207
183
  // next();
208
184
  // }
209
- // );
210
185
 
211
- // export const beforeDeleteOne = catchAsync(
186
+ // export const beforeDeleteOne =
212
187
  // async (${functionParams}) => {
213
188
  // // Your logic here
214
189
  // next();
215
190
  // }
216
- // );
217
191
 
218
- // export const afterDeleteOne = catchAsync(
192
+ // export const afterDeleteOne =
219
193
  // async (${functionParams}) => {
220
194
  // // Your logic here
221
195
  // next();
222
196
  // }
223
- // );
224
197
 
225
- // export const beforeCreateMany = catchAsync(
198
+ // export const beforeCreateMany =
226
199
  // async (${functionParams}) => {
227
200
  // // Your logic here
228
201
  // next();
229
202
  // }
230
- // );
231
203
 
232
- // export const afterCreateMany = catchAsync(
204
+ // export const afterCreateMany =
233
205
  // async (${functionParams}) => {
234
206
  // // Your logic here
235
207
  // next();
236
208
  // }
237
- // );
238
209
 
239
- // export const beforeUpdateMany = catchAsync(
210
+ // export const beforeUpdateMany =
240
211
  // async (${functionParams}) => {
241
212
  // // Your logic here
242
213
  // next();
243
214
  // }
244
- // );
245
215
 
246
- // export const afterUpdateMany = catchAsync(
216
+ // export const afterUpdateMany =
247
217
  // async (${functionParams}) => {
248
218
  // // Your logic here
249
219
  // next();
250
220
  // }
251
- // );
252
221
 
253
- // export const beforeDeleteMany = catchAsync(
222
+ // export const beforeDeleteMany =
254
223
  // async (${functionParams}) => {
255
224
  // // Your logic here
256
225
  // next();
257
226
  // }
258
- // );
259
227
 
260
- // export const afterDeleteMany = catchAsync(
228
+ // export const afterDeleteMany =
261
229
  // async (${functionParams}) => {
262
230
  // // Your logic here
263
231
  // next();
264
232
  // }
265
- // );
266
233
  `;
267
234
  }
268
235
  //# 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":";;AAGA,kEAiRC;AApRD,+DAAsE;AAGtE,SAAgB,2BAA2B,CAAC,OAAwB;IAClE,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC9B,MAAM,GAAG,GAAG,IAAA,iCAAoB,GAAE,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;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;CAK3B,CAAC;IACA,CAAC;IAED,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,GAAG,WAAW;;;;cAIX,cAAc;;;;;;;;;cASd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;CAK3B,CAAC;IACA,CAAC;IAGD,OAAO,GAAG,WAAW;;;cAGT,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;;;cAOd,cAAc;;;;;CAK3B,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 = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const afterGetMe = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const beforeLogin = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const afterLogin = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const beforeLogout = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const afterLogout = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const beforeSignup = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const afterSignup = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const beforeUpdatePassword = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const afterUpdatePassword = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n`;\n }\n\n if (isFileUpload) {\n return `${baseImports}\n\n\n// export const beforeFindFile = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// There is not afterFindFile: because the main handler is handleded by express.static()\n\n// export const beforeUploadFile = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const afterUploadFile = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const beforeUpdateFile = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const afterUpdateFile = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const beforeDeleteFile = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const afterDeleteFile = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n`;\n }\n\n // Regular model middlewares\n return `${baseImports}\n\n// export const beforeCreateOne = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const afterCreateOne = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const beforeFindOne = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const afterFindOne = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const beforeFindMany = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const afterFindMany = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const beforeUpdateOne = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const afterUpdateOne = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const beforeDeleteOne = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const afterDeleteOne = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const beforeCreateMany = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const afterCreateMany = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const beforeUpdateMany = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const afterUpdateMany = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const beforeDeleteMany = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n\n// export const afterDeleteMany = catchAsync(\n// async (${functionParams}) => {\n// // Your logic here\n// next();\n// }\n// );\n`;\n}\n"]}
1
+ {"version":3,"file":"generate-middlewares.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/generate-middlewares.ts"],"names":[],"mappings":";;AAGA,kEAgPC;AAnPD,+DAAsE;AAGtE,SAAgB,2BAA2B,CAAC,OAAwB;IAClE,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC9B,MAAM,GAAG,GAAG,IAAA,iCAAoB,GAAE,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"]}
@@ -39,16 +39,22 @@ export default ${modelName.camel}QueryOptions;
39
39
  return `${prismaImport}${imports};
40
40
 
41
41
  const ${modelName.camel}QueryOptions${typeAnnotation} = {
42
- // for all queries
43
- queryOptions: {},
44
- findOne: {},
45
- findMany: {},
46
- deleteMany: {},
47
- updateMany: {},
48
- createMany: {},
49
- createOne: {},
50
- updateOne: {},
51
- deleteOne: {},
42
+ global: {},
43
+ find: {},
44
+ findOne: {},
45
+ findMany: {},
46
+ udpate: {},
47
+ updateMany: {},
48
+ updateOne: {},
49
+ create: {},
50
+ createMany: {},
51
+ createOne: {},
52
+ save: {},
53
+ saveMany: {},
54
+ saveOne: {},
55
+ delete: {},
56
+ deleteMany: {},
57
+ deleteOne: {},
52
58
  }
53
59
 
54
60
  export default ${modelName.camel}QueryOptions;
@@ -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":";;AAGA,oEA6DC;AAhED,+DAAsE;AAGtE,SAAgB,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,IAAA,iCAAoB,GAAE,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;;;;;;;;;;;;;iBAanC,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 // for all queries\n queryOptions: {},\n findOne: {},\n findMany: {},\n deleteMany: {},\n updateMany: {},\n createMany: {},\n createOne: {},\n updateOne: {},\n deleteOne: {},\n}\n\nexport default ${modelName.camel}QueryOptions;\n`;\n }\n}\n"]}
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":";;AAGA,oEAmEC;AAtED,+DAAsE;AAGtE,SAAgB,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,IAAA,iCAAoB,GAAE,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"]}
@@ -12,6 +12,8 @@ function generateRouterTemplate(options) {
12
12
  throw new Error("Model name is required for router template");
13
13
  const ext = (0, fs_helpers_1.getUserFileExtension)();
14
14
  const controllerPath = imports?.controller || `./${modelName.kebab}.controller.${ext}`;
15
+ const routerConfigTsType = ext === "ts" ? ": RouterConfig" : "";
16
+ const routerConfigTsTypeImport = ext === "ts" ? "import { RouterConfig } from 'arkos'" : "";
15
17
  const controllerExists = (0, fs_helpers_1.checkFileExists)(controllerPath);
16
18
  const controllerImportLine = controllerExists
17
19
  ? `import ${modelName.camel}Controller from "${imports?.controller || `./${modelName.kebab}.controller`}"`
@@ -22,6 +24,9 @@ function generateRouterTemplate(options) {
22
24
  return `import { Router } from 'express'
23
25
  import { authService } from 'arkos/services'
24
26
  ${controllerImportLine}
27
+ ${routerConfigTsTypeImport}
28
+
29
+ export const config${routerConfigTsType} = { }
25
30
 
26
31
  const ${modelName.camel}Router = Router()
27
32
 
@@ -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":";;;;;AAOA,wDAyCC;AAhDD,0DAAkC;AAClC,+DAGwC;AAGxC,SAAgB,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,IAAA,iCAAoB,GAAE,CAAC;IACnC,MAAM,cAAc,GAClB,OAAO,EAAE,UAAU,IAAI,KAAK,SAAS,CAAC,KAAK,eAAe,GAAG,EAAE,CAAC;IAElE,MAAM,gBAAgB,GAAG,IAAA,4BAAe,EAAC,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;;QAEd,SAAS,CAAC,KAAK;;EAErB,SAAS,CAAC,KAAK;4CAC2B,IAAA,mBAAS,EACjD,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 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\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
+ {"version":3,"file":"generate-router-template.js","sourceRoot":"","sources":["../../../../../../../src/utils/cli/utils/template-generator/templates/generate-router-template.ts"],"names":[],"mappings":";;;;;AAOA,wDAgDC;AAvDD,0DAAkC;AAClC,+DAGwC;AAGxC,SAAgB,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,IAAA,iCAAoB,GAAE,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,IAAA,4BAAe,EAAC,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,IAAA,mBAAS,EACjD,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"]}
@@ -39,6 +39,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.getPackageJson = getPackageJson;
40
40
  exports.isEsm = isEsm;
41
41
  exports.importModule = importModule;
42
+ exports.detectPackageManagerFromUserAgent = detectPackageManagerFromUserAgent;
42
43
  const fs_1 = __importDefault(require("fs"));
43
44
  const path_1 = __importDefault(require("path"));
44
45
  function getPackageJson() {
@@ -73,4 +74,24 @@ async function importModule(modulePath, options = { fixExtension: true }) {
73
74
  }
74
75
  return await Promise.resolve(`${correctedPath}`).then(s => __importStar(require(s)));
75
76
  }
77
+ function detectPackageManagerFromUserAgent() {
78
+ const userAgent = process.env.npm_config_user_agent || "";
79
+ if (!userAgent)
80
+ return "npm";
81
+ if (userAgent.includes("pnpm"))
82
+ return "pnpm";
83
+ if (userAgent.includes("yarn"))
84
+ return "yarn";
85
+ if (userAgent.includes("npm"))
86
+ return "npm";
87
+ if (userAgent.includes("bun"))
88
+ return "bun";
89
+ if (userAgent.includes("cnpm"))
90
+ return "cnpm";
91
+ if (userAgent.includes("corepack"))
92
+ return "corepack";
93
+ if (userAgent.includes("deno"))
94
+ return "deno";
95
+ return "npm";
96
+ }
76
97
  //# sourceMappingURL=global.helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"global.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/global.helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,wCASC;AAED,sBAGC;AAED,oCAyBC;AA5CD,4CAAoB;AACpB,gDAAwB;AAExB,SAAgB,cAAc;IAC5B,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC,CAAC;QACzD,IAAI,YAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC,KAAK,CAAC,YAAE,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,GAAG,CAAC,CAAC;IACrD,CAAC;AACH,CAAC;AAED,SAAgB,KAAK;IACnB,MAAM,GAAG,GAAG,cAAc,EAAE,CAAC;IAC7B,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ,CAAC;AAC/B,CAAC;AAEM,KAAK,UAAU,YAAY,CAChC,UAAkB,EAClB,UAAqC,EAAE,YAAY,EAAE,IAAI,EAAE;IAG3D,IAAI,aAAa,GAAG,UAAU,CAAC;IAE/B,IACE,OAAO,EAAE,YAAY;QACrB,KAAK,EAAE;QACP,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC;QAC1B,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,EAC3B,CAAC;QACD,MAAM,cAAc,GAAG,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,UAAU,CAAC,CAAC;QAC/D,MAAM,SAAS,GAAG,cAAc,GAAG,WAAW,CAAC;QAG/C,IAAI,YAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YAC7B,aAAa,GAAG,UAAU,GAAG,WAAW,CAAC;QAC3C,CAAC;aAAM,CAAC;YACN,aAAa,GAAG,UAAU,GAAG,KAAK,CAAC;QACrC,CAAC;IACH,CAAC;IAED,OAAO,yBAAa,aAAa,uCAAC,CAAC;AACrC,CAAC","sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\n\nexport function getPackageJson() {\n try {\n const pkgPath = path.join(process.cwd(), \"package.json\");\n if (fs.existsSync(pkgPath)) {\n return JSON.parse(fs.readFileSync(pkgPath, \"utf8\"));\n }\n } catch (err) {\n console.error(\"Error checking package.json:\", err);\n }\n}\n\nexport function isEsm() {\n const pkg = getPackageJson();\n return pkg.type === \"module\";\n}\n\nexport async function importModule(\n modulePath: string,\n options: { fixExtension: boolean } = { fixExtension: true }\n) {\n // Add .js extension if it's a relative path without extension\n let correctedPath = modulePath;\n\n if (\n options?.fixExtension &&\n isEsm() &&\n modulePath.startsWith(\".\") &&\n !modulePath.endsWith(\".js\")\n ) {\n const fullImportPath = path.resolve(process.cwd(), modulePath);\n const indexPath = fullImportPath + \"/index.js\";\n\n // Check if it's a directory with index.js or a direct file\n if (fs.existsSync(indexPath)) {\n correctedPath = modulePath + \"/index.js\";\n } else {\n correctedPath = modulePath + \".js\";\n }\n }\n\n return await import(correctedPath);\n}\n"]}
1
+ {"version":3,"file":"global.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/global.helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,wCASC;AAED,sBAGC;AAED,oCAyBC;AAQD,8EAaC;AAjED,4CAAoB;AACpB,gDAAwB;AAExB,SAAgB,cAAc;IAC5B,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC,CAAC;QACzD,IAAI,YAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC,KAAK,CAAC,YAAE,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,GAAG,CAAC,CAAC;IACrD,CAAC;AACH,CAAC;AAED,SAAgB,KAAK;IACnB,MAAM,GAAG,GAAG,cAAc,EAAE,CAAC;IAC7B,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ,CAAC;AAC/B,CAAC;AAEM,KAAK,UAAU,YAAY,CAChC,UAAkB,EAClB,UAAqC,EAAE,YAAY,EAAE,IAAI,EAAE;IAG3D,IAAI,aAAa,GAAG,UAAU,CAAC;IAE/B,IACE,OAAO,EAAE,YAAY;QACrB,KAAK,EAAE;QACP,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC;QAC1B,CAAC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");\n if (fs.existsSync(pkgPath)) {\n return JSON.parse(fs.readFileSync(pkgPath, \"utf8\"));\n }\n } catch (err) {\n console.error(\"Error checking package.json:\", err);\n }\n}\n\nexport function isEsm() {\n const pkg = getPackageJson();\n return pkg.type === \"module\";\n}\n\nexport async function importModule(\n modulePath: string,\n options: { fixExtension: boolean } = { fixExtension: true }\n) {\n // Add .js extension if it's a relative path without extension\n let correctedPath = modulePath;\n\n if (\n options?.fixExtension &&\n isEsm() &&\n modulePath.startsWith(\".\") &&\n !modulePath.endsWith(\".js\")\n ) {\n const fullImportPath = path.resolve(process.cwd(), modulePath);\n const indexPath = fullImportPath + \"/index.js\";\n\n // Check if it's a directory with index.js or a direct file\n if (fs.existsSync(indexPath)) {\n correctedPath = modulePath + \"/index.js\";\n } else {\n correctedPath = modulePath + \".js\";\n }\n }\n\n return await import(correctedPath);\n}\n\n/**\n * Helps getting the current package manager from user agent\n *\n * @returns {string} the package manager\n * @default \"npm\"\n */\nexport function detectPackageManagerFromUserAgent(): string {\n const userAgent = process.env.npm_config_user_agent || \"\";\n\n if (!userAgent) return \"npm\";\n if (userAgent.includes(\"pnpm\")) return \"pnpm\";\n if (userAgent.includes(\"yarn\")) return \"yarn\";\n if (userAgent.includes(\"npm\")) return \"npm\";\n if (userAgent.includes(\"bun\")) return \"bun\";\n if (userAgent.includes(\"cnpm\")) return \"cnpm\";\n if (userAgent.includes(\"corepack\")) return \"corepack\";\n if (userAgent.includes(\"deno\")) return \"deno\";\n\n return \"npm\";\n}\n"]}
@@ -283,7 +283,6 @@ function initializePrismaModels() {
283
283
  }
284
284
  }
285
285
  }
286
- initializePrismaModels();
287
286
  function getPrismaModelRelations(modelName) {
288
287
  modelName = (0, change_case_helpers_1.pascalCase)(modelName);
289
288
  if (!(modelName in exports.prismaModelRelationFields))
@@ -1 +1 @@
1
- {"version":3,"file":"models.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/models.helpers.ts"],"names":[],"mappings":";;;;;;AAkBA,0CAE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,SAAS;qBAChB,CAAC,CAAC;gBACL,CAAC;qBAAM,CAAC;oBACN,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;wBAClB,IAAI,EAAE,SAAS;wBACf,IAAI,EAAE,SAAS;qBAChB,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;YAED,iCAAyB,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;QACnD,CAAC;IACH,CAAC;AACH,CAAC;AAED,sBAAsB,EAAE,CAAC;AAQzB,SAAgB,uBAAuB,CACrC,SAAiB;IAEjB,SAAS,GAAG,IAAA,gCAAU,EAAC,SAAS,CAAC,CAAC;IAElC,IAAI,CAAC,CAAC,SAAS,IAAI,iCAAyB,CAAC;QAAE,OAAO;IACtD,OAAO,iCAAyB,CAAC,SAAS,CAAC,CAAC;AAC9C,CAAC;AAOD,SAAS,SAAS;IAChB,OAAO,cAAM,CAAC;AAChB,CAAC;AAOD,SAAgB,uBAAuB;IACrC,OAAO,4BAAoB,CAAC;AAC9B,CAAC;AAMD,SAAS,oBAAoB,CAAC,SAAiB;IAC7C,OAAO,gCAAwB,CAAC,SAAS,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["import path from \"path\";\nimport fs from \"fs\";\nimport {\n camelCase,\n kebabCase,\n pascalCase,\n} from \"../../utils/helpers/change-case.helpers\";\nimport { crd, getUserFileExtension } from \"./fs.helpers\";\nimport { importModule } from \"./global.helpers\";\nimport { AuthConfigs } from \"../../types/auth\";\nimport { killServerChildProcess } from \"../cli/utils/cli.helpers\";\n\n// Must be exported to not cause problems on cjs\nlet prismaModelsModules: Record<\n string,\n Awaited<ReturnType<typeof importPrismaModelModules>>\n> = {};\n\nexport function getModelModules(modelName: string) {\n return prismaModelsModules[kebabCase(modelName)];\n}\n\nexport function getFileModelModulesFileStructure(modelName: string) {\n const kebabModelName = kebabCase(modelName).toLowerCase();\n const isAuthModule = modelName.toLowerCase() === \"auth\";\n const ext = getUserFileExtension();\n\n return {\n core: {\n service: `${kebabModelName}.service.${ext}`,\n controller: `${kebabModelName}.controller.${ext}`,\n middlewares: `${kebabModelName}.middlewares.${ext}`,\n authConfigs: `${kebabModelName}.auth-configs.${ext}`,\n authConfigsNew: `${kebabModelName}.auth.${ext}`,\n prismaQueryOptions: `${kebabModelName}.prisma-query-options.${ext}`,\n prismaQueryOptionsNew: `${kebabModelName}.query.${ext}`,\n router: `${kebabModelName}.router.${ext}`,\n },\n dtos: isAuthModule\n ? {\n login: `login.dto.${ext}`,\n signup: `signup.dto.${ext}`,\n updateMe: `update-me.dto.${ext}`,\n updatePassword: `update-password.dto.${ext}`,\n }\n : {\n model: `${kebabModelName}.dto.${ext}`,\n create: `create-${kebabModelName}.dto.${ext}`,\n createMany: `create-many-${kebabModelName}.dto.${ext}`,\n update: `update-${kebabModelName}.dto.${ext}`,\n updateMany: `update-many-${kebabModelName}.dto.${ext}`,\n findOne: `find-one-${kebabModelName}.dto.${ext}`,\n findMany: `find-many-${kebabModelName}.dto.${ext}`,\n query: `query-${kebabModelName}.dto.${ext}`,\n },\n schemas: isAuthModule\n ? {\n login: `login.schema.${ext}`,\n signup: `signup.schema.${ext}`,\n updateMe: `update-me.schema.${ext}`,\n updatePassword: `update-password.schema.${ext}`,\n }\n : {\n model: `${kebabModelName}.schema.${ext}`,\n create: `create-${kebabModelName}.schema.${ext}`,\n createMany: `create-many-${kebabModelName}.schema.${ext}`,\n update: `update-${kebabModelName}.schema.${ext}`,\n updateMany: `update-many-${kebabModelName}.schema.${ext}`,\n findOne: `find-one-${kebabModelName}.schema.${ext}`,\n findMany: `find-many-${kebabModelName}.schema.${ext}`,\n query: `query-${kebabModelName}.schema.${ext}`,\n },\n };\n}\n\nexport async function processSubdir(\n modelName: string,\n type: \"dtos\" | \"schemas\",\n result: Record<string, any>\n) {\n const moduleDir = path.resolve(crd(), \"src\", \"modules\", kebabCase(modelName));\n\n const subdir = path.join(moduleDir, type);\n const fileStructure = getFileModelModulesFileStructure(modelName);\n\n // Skip if directory doesn't exist\n try {\n await fs.promises.access(subdir).catch(() => {\n return; // Directory doesn't exist\n });\n\n await Promise.all(\n Object.entries(fileStructure[type]).map(async ([key, fileName]) => {\n const filePath = path.join(subdir, fileName);\n try {\n const module = await importModule(filePath).catch(() => null);\n if (module) result[type][key] = module.default;\n } catch (error) {\n // Silent fail - file might not exist\n console.error(error);\n }\n })\n );\n } catch (error) {\n // Directory doesn't exist, continue silently\n console.error(error);\n }\n}\n\ntype importPrismaModelModulesReturnType = {\n service?: any;\n controller?: any;\n middlewares?: any;\n authConfigs?: AuthConfigs;\n authConfigsNew?: AuthConfigs;\n prismaQueryOptions?: any;\n prismaQueryOptionsNew?: any;\n router?: any;\n dtos: Record<string, any>;\n schemas: Record<string, any>;\n};\n\n/**\n * Validates naming convention conflicts for prismaQueryOptions and authConfigs\n * @param {string} key - The current file key being processed\n * @param {string} fileName - The filename being imported\n * @param {importPrismaModelModulesReturnType} result - The current result object\n * @throws {Error} When conflicting naming conventions are detected\n */\nexport function validateNamingConventions(\n key: string,\n fileName: string,\n result: importPrismaModelModulesReturnType\n): void {\n if (key === \"prismaQueryOptions\") {\n if (result.prismaQueryOptions) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"prisma-query-options\",\n \"query\"\n )} at once, please choose only one name convention. \\n`\n );\n }\n } else if (key === \"prismaQueryOptionsNew\") {\n if (result.prismaQueryOptions) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"query\",\n \"prisma-query-options\"\n )} at once, please choose only one name convention. \\n`\n );\n }\n } else if (key === \"authConfigs\") {\n if (result.authConfigs) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"auth-configs\",\n \"auth\"\n )} at once, please choose only one name convention. \\n`\n );\n }\n } else if (key === \"authConfigsNew\") {\n if (result.authConfigs) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"auth\",\n \"auth-configs\"\n )} at once, please choose only one name convention. \\n`\n );\n }\n }\n}\n\n/**\n * Processes and assigns module to the result object based on the key\n * @param {string} key - The file key being processed\n * @param {any} module - The imported module\n * @param {importPrismaModelModulesReturnType} result - The result object to modify\n */\nexport function assignModuleToResult(\n key: string,\n module: any,\n result: importPrismaModelModulesReturnType\n): void {\n if (key === \"prismaQueryOptions\" || key === \"prismaQueryOptionsNew\") {\n result.prismaQueryOptions = module.default || module;\n } else if (key === \"authConfigs\" || key === \"authConfigsNew\") {\n result.authConfigs = module.default || module;\n } else if (key === \"middlewares\" || key === \"router\") {\n result[key] = module;\n } else {\n result[key as keyof typeof result] = module.default || module;\n }\n}\n\n/**\n * Dynamically imports model-specific modules for a given model with optimized file handling.\n * Includes special handling for the Auth module.\n *\n * @param {string} modelName - The name of the model (e.g., \"User\", \"Post\", \"Auth\").\n * @returns {Promise<Object>} An object containing the imported modules\n */\nexport async function importPrismaModelModules(\n modelName: string\n): Promise<importPrismaModelModulesReturnType> {\n const moduleDir = path.resolve(crd(), \"src\", \"modules\", kebabCase(modelName));\n\n const result: importPrismaModelModulesReturnType = {\n dtos: {},\n schemas: {},\n };\n\n if (getModelModules(modelName)) return getModelModules(modelName);\n\n const fileStructure = getFileModelModulesFileStructure(modelName);\n\n // Batch process core files\n await Promise.all(\n Object.entries(fileStructure.core).map(async ([key, fileName]) => {\n const filePath = path.join(moduleDir, fileName);\n try {\n const module = await importModule(filePath).catch((err) => {\n if (!err.message.includes(\"Cannot find module\")) {\n console.error(`Failed to import ${fileName}: \\n`);\n console.error(err);\n killServerChildProcess();\n process.exit(1);\n }\n });\n\n if (module) {\n // Validate naming conventions before assignment\n validateNamingConventions(key, fileName, result);\n\n // Assign module to result\n assignModuleToResult(key, module, result);\n }\n } catch (err: any) {\n if (err.message.includes(\"Cannot use both\")) throw err;\n console.error(err);\n killServerChildProcess();\n }\n })\n );\n\n await Promise.all([\n processSubdir(modelName, \"dtos\", result),\n processSubdir(modelName, \"schemas\", result),\n ]);\n\n // Removed because caused problems with cached ZObjects\n // Cache the result making shallow copy to not cause problems after build\n // prismaModelsModules[modelName] = JSON.parse(JSON.stringify(result));\n prismaModelsModules[modelName] = result;\n\n return result;\n}\n\nexport type ModelFieldDefition = {\n name: string;\n type: string;\n isUnique: boolean;\n};\n\n/**\n * Represents the structure of relation fields for Prisma models.\n * It includes both singular (one-to-one) and list (one-to-many) relationships.\n *\n * @typedef {Object} RelationFields\n * @property {Array<{name: string, type: string}>} singular - List of singular relationships.\n * @property {Array<{name: string, type: string}>} list - List of list relationships.\n */\nexport type RelationFields = {\n singular: Omit<ModelFieldDefition, \"isUnique\">[];\n list: Omit<ModelFieldDefition, \"isUnique\">[];\n};\n\n/**\n * Reads the Prisma schema files and extracts all model definitions,\n * identifying their relations (one-to-one and one-to-many).\n */\nexport const prismaModelRelationFields: Record<string, RelationFields> = {};\n\nexport function getAllPrismaFiles(dirPath: string, fileList: string[] = []) {\n const files = fs.readdirSync(dirPath);\n\n files?.forEach((file) => {\n const filePath = path.join(dirPath, file);\n const stat = fs.statSync(filePath);\n\n // Skip migrations folder\n if (stat.isDirectory() && file !== \"migrations\") {\n fileList = getAllPrismaFiles(filePath, fileList);\n } else if (stat.isFile() && file.endsWith(\".prisma\")) {\n fileList.push(filePath);\n }\n });\n\n return fileList;\n}\n\nconst modelRegex = /model\\s+(\\w+)\\s*{/g;\nexport const models: string[] = [];\nexport let prismaSchemasContent: string;\nexport const prismaModelsUniqueFields: Record<string, ModelFieldDefition[]> =\n [] as any;\n\nexport function initializePrismaModels() {\n const prismaContent: string[] = [];\n\n const files = getAllPrismaFiles(\"./prisma\");\n\n for (const file of files) {\n const content = fs.readFileSync(file, \"utf-8\");\n\n if (!prismaContent?.includes?.(content)) prismaContent.push(content);\n }\n\n // Gather the content of all *.prisma files into single one\n const content = prismaContent\n .join(\"\\n\")\n .replace(modelRegex, (_, modelName) => {\n if (!models?.includes?.(modelName))\n models.push(camelCase(modelName.trim()));\n return `model ${modelName} {`;\n });\n\n const copiedContent = content;\n prismaSchemasContent = content;\n\n for (const model of models) {\n const modelName = pascalCase(model);\n\n const modelStart = copiedContent.indexOf(`model ${modelName} {`);\n const modelEnd = copiedContent.indexOf(\"}\", modelStart);\n const modelDefinition = copiedContent.slice(modelStart, modelEnd);\n\n const relations: RelationFields = {\n singular: [],\n list: [],\n };\n const lines = modelDefinition.split(\"\\n\");\n\n for (const line of lines) {\n const trimmedLine = line.trim();\n\n if (\n !trimmedLine ||\n trimmedLine.startsWith(\"model\") ||\n trimmedLine.startsWith(\"//\") ||\n trimmedLine.startsWith(\"/*\")\n )\n continue;\n\n const [fieldName, type] = trimmedLine.split(/\\s+/);\n const isUnique = trimmedLine?.includes?.(\"@unique\");\n\n if (isUnique) {\n const existingFields = prismaModelsUniqueFields[model] || [];\n\n const alreadyExists = existingFields.some(\n (field) =>\n field.name === fieldName &&\n field.type === type &&\n field.isUnique === isUnique\n );\n\n if (!alreadyExists) {\n prismaModelsUniqueFields[model] = [\n ...existingFields,\n { name: fieldName, type, isUnique },\n ];\n }\n }\n\n const cleanType = type?.replace(\"[]\", \"\").replace(\"?\", \"\");\n\n if (\n trimmedLine?.includes?.(\"@relation\") ||\n trimmedLine.match(/\\s+\\w+(\\[\\])?(\\s+@|$)/) ||\n models?.includes?.(camelCase(cleanType || \"\"))\n ) {\n const enumStart = copiedContent.indexOf(`enum ${cleanType} {`);\n const typeStart = copiedContent.indexOf(`type ${cleanType} {`);\n\n if (\n !cleanType ||\n enumStart >= 0 ||\n typeStart >= 0 ||\n cleanType === \"String\" ||\n cleanType === \"Int\" ||\n cleanType === \"Float\" ||\n cleanType === \"Boolean\" ||\n cleanType === \"DateTime\" ||\n cleanType === \"Bytes\" ||\n cleanType === \"Decimal\" ||\n cleanType === \"BigInt\" ||\n cleanType === \"Json\"\n\n // && !content.includes?.(`model ${cleanType} {`)\n ) {\n continue;\n }\n\n if (!type?.includes?.(\"[]\")) {\n relations.singular.push({\n name: fieldName,\n type: cleanType,\n });\n } else {\n relations.list.push({\n name: fieldName,\n type: cleanType,\n });\n }\n }\n\n prismaModelRelationFields[modelName] = relations;\n }\n }\n}\n\ninitializePrismaModels();\n\n/**\n * Retrieves the relations for a given Prisma model.\n *\n * @param {string} modelName - The name of the model (e.g., \"User\").\n * @returns {RelationFields|undefined} The relation fields for the model, or `undefined` if no relations are found.\n */\nexport function getPrismaModelRelations(\n modelName: string\n): RelationFields | undefined {\n modelName = pascalCase(modelName);\n\n if (!(modelName in prismaModelRelationFields)) return;\n return prismaModelRelationFields[modelName];\n}\n\n/**\n * Retrieves all the model names from the Prisma schema.\n *\n * @returns {string[]} An array of model names (e.g., [\"User\", \"Post\"]).\n */\nfunction getModels(): string[] {\n return models;\n}\n\n/**\n * Returns all content of all .prisma files gathered together\n *\n * @returns {string}\n */\nexport function getPrismaSchemasContent(): string {\n return prismaSchemasContent;\n}\n\n/** Retuns a given model unique fields\n * @param {string} modelName - The name of model in PascalCase\n * @returns {string[]} An array of all unique fields,\n */\nfunction getModelUniqueFields(modelName: string): ModelFieldDefition[] {\n return prismaModelsUniqueFields[modelName];\n}\n\nexport { getModels, getModelUniqueFields };\n"]}
1
+ {"version":3,"file":"models.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/models.helpers.ts"],"names":[],"mappings":";;;;;;AAkBA,0CAEC;AAED,4EAmDC;AAED,sCAgCC;AAsBD,8DA8CC;AAQD,oDAcC;AASD,4DAsDC;AA2BD,8CAgBC;AAQD,wDA+GC;AAUD,0DAOC;AAgBD,0DAEC;AAUQ,8BAAS;AAAE,oDAAoB;AAndxC,gDAAwB;AACxB,4CAAoB;AACpB,iFAIiD;AACjD,6CAAyD;AACzD,qDAAgD;AAEhD,0DAAkE;AAGlE,IAAI,mBAAmB,GAGnB,EAAE,CAAC;AAEP,SAAgB,eAAe,CAAC,SAAiB;IAC/C,OAAO,mBAAmB,CAAC,IAAA,+BAAS,EAAC,SAAS,CAAC,CAAC,CAAC;AACnD,CAAC;AAED,SAAg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E,OAAO;IACtD,OAAO,iCAAyB,CAAC,SAAS,CAAC,CAAC;AAC9C,CAAC;AAOD,SAAS,SAAS;IAChB,OAAO,cAAM,CAAC;AAChB,CAAC;AAOD,SAAgB,uBAAuB;IACrC,OAAO,4BAAoB,CAAC;AAC9B,CAAC;AAMD,SAAS,oBAAoB,CAAC,SAAiB;IAC7C,OAAO,gCAAwB,CAAC,SAAS,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["import path from \"path\";\nimport fs from \"fs\";\nimport {\n camelCase,\n kebabCase,\n pascalCase,\n} from \"../../utils/helpers/change-case.helpers\";\nimport { crd, getUserFileExtension } from \"./fs.helpers\";\nimport { importModule } from \"./global.helpers\";\nimport { AuthConfigs } from \"../../types/auth\";\nimport { killServerChildProcess } from \"../cli/utils/cli.helpers\";\n\n// Must be exported to not cause problems on cjs\nlet prismaModelsModules: Record<\n string,\n Awaited<ReturnType<typeof importPrismaModelModules>>\n> = {};\n\nexport function getModelModules(modelName: string) {\n return prismaModelsModules[kebabCase(modelName)];\n}\n\nexport function getFileModelModulesFileStructure(modelName: string) {\n const kebabModelName = kebabCase(modelName).toLowerCase();\n const isAuthModule = modelName.toLowerCase() === \"auth\";\n const ext = getUserFileExtension();\n\n return {\n core: {\n service: `${kebabModelName}.service.${ext}`,\n controller: `${kebabModelName}.controller.${ext}`,\n middlewares: `${kebabModelName}.middlewares.${ext}`,\n authConfigs: `${kebabModelName}.auth-configs.${ext}`,\n authConfigsNew: `${kebabModelName}.auth.${ext}`,\n prismaQueryOptions: `${kebabModelName}.prisma-query-options.${ext}`,\n prismaQueryOptionsNew: `${kebabModelName}.query.${ext}`,\n router: `${kebabModelName}.router.${ext}`,\n },\n dtos: isAuthModule\n ? {\n login: `login.dto.${ext}`,\n signup: `signup.dto.${ext}`,\n updateMe: `update-me.dto.${ext}`,\n updatePassword: `update-password.dto.${ext}`,\n }\n : {\n model: `${kebabModelName}.dto.${ext}`,\n create: `create-${kebabModelName}.dto.${ext}`,\n createMany: `create-many-${kebabModelName}.dto.${ext}`,\n update: `update-${kebabModelName}.dto.${ext}`,\n updateMany: `update-many-${kebabModelName}.dto.${ext}`,\n findOne: `find-one-${kebabModelName}.dto.${ext}`,\n findMany: `find-many-${kebabModelName}.dto.${ext}`,\n query: `query-${kebabModelName}.dto.${ext}`,\n },\n schemas: isAuthModule\n ? {\n login: `login.schema.${ext}`,\n signup: `signup.schema.${ext}`,\n updateMe: `update-me.schema.${ext}`,\n updatePassword: `update-password.schema.${ext}`,\n }\n : {\n model: `${kebabModelName}.schema.${ext}`,\n create: `create-${kebabModelName}.schema.${ext}`,\n createMany: `create-many-${kebabModelName}.schema.${ext}`,\n update: `update-${kebabModelName}.schema.${ext}`,\n updateMany: `update-many-${kebabModelName}.schema.${ext}`,\n findOne: `find-one-${kebabModelName}.schema.${ext}`,\n findMany: `find-many-${kebabModelName}.schema.${ext}`,\n query: `query-${kebabModelName}.schema.${ext}`,\n },\n };\n}\n\nexport async function processSubdir(\n modelName: string,\n type: \"dtos\" | \"schemas\",\n result: Record<string, any>\n) {\n const moduleDir = path.resolve(crd(), \"src\", \"modules\", kebabCase(modelName));\n\n const subdir = path.join(moduleDir, type);\n const fileStructure = getFileModelModulesFileStructure(modelName);\n\n // Skip if directory doesn't exist\n try {\n await fs.promises.access(subdir).catch(() => {\n return; // Directory doesn't exist\n });\n\n await Promise.all(\n Object.entries(fileStructure[type]).map(async ([key, fileName]) => {\n const filePath = path.join(subdir, fileName);\n try {\n const module = await importModule(filePath).catch(() => null);\n if (module) result[type][key] = module.default;\n } catch (error) {\n // Silent fail - file might not exist\n console.error(error);\n }\n })\n );\n } catch (error) {\n // Directory doesn't exist, continue silently\n console.error(error);\n }\n}\n\ntype importPrismaModelModulesReturnType = {\n service?: any;\n controller?: any;\n middlewares?: any;\n authConfigs?: AuthConfigs;\n authConfigsNew?: AuthConfigs;\n prismaQueryOptions?: any;\n prismaQueryOptionsNew?: any;\n router?: any;\n dtos: Record<string, any>;\n schemas: Record<string, any>;\n};\n\n/**\n * Validates naming convention conflicts for prismaQueryOptions and authConfigs\n * @param {string} key - The current file key being processed\n * @param {string} fileName - The filename being imported\n * @param {importPrismaModelModulesReturnType} result - The current result object\n * @throws {Error} When conflicting naming conventions are detected\n */\nexport function validateNamingConventions(\n key: string,\n fileName: string,\n result: importPrismaModelModulesReturnType\n): void {\n if (key === \"prismaQueryOptions\") {\n if (result.prismaQueryOptions) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"prisma-query-options\",\n \"query\"\n )} at once, please choose only one name convention. \\n`\n );\n }\n } else if (key === \"prismaQueryOptionsNew\") {\n if (result.prismaQueryOptions) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"query\",\n \"prisma-query-options\"\n )} at once, please choose only one name convention. \\n`\n );\n }\n } else if (key === \"authConfigs\") {\n if (result.authConfigs) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"auth-configs\",\n \"auth\"\n )} at once, please choose only one name convention. \\n`\n );\n }\n } else if (key === \"authConfigsNew\") {\n if (result.authConfigs) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"auth\",\n \"auth-configs\"\n )} at once, please choose only one name convention. \\n`\n );\n }\n }\n}\n\n/**\n * Processes and assigns module to the result object based on the key\n * @param {string} key - The file key being processed\n * @param {any} module - The imported module\n * @param {importPrismaModelModulesReturnType} result - The result object to modify\n */\nexport function assignModuleToResult(\n key: string,\n module: any,\n result: importPrismaModelModulesReturnType\n): void {\n if (key === \"prismaQueryOptions\" || key === \"prismaQueryOptionsNew\") {\n result.prismaQueryOptions = module.default || module;\n } else if (key === \"authConfigs\" || key === \"authConfigsNew\") {\n result.authConfigs = module.default || module;\n } else if (key === \"middlewares\" || key === \"router\") {\n result[key] = module;\n } else {\n result[key as keyof typeof result] = module.default || module;\n }\n}\n\n/**\n * Dynamically imports model-specific modules for a given model with optimized file handling.\n * Includes special handling for the Auth module.\n *\n * @param {string} modelName - The name of the model (e.g., \"User\", \"Post\", \"Auth\").\n * @returns {Promise<Object>} An object containing the imported modules\n */\nexport async function importPrismaModelModules(\n modelName: string\n): Promise<importPrismaModelModulesReturnType> {\n const moduleDir = path.resolve(crd(), \"src\", \"modules\", kebabCase(modelName));\n\n const result: importPrismaModelModulesReturnType = {\n dtos: {},\n schemas: {},\n };\n\n if (getModelModules(modelName)) return getModelModules(modelName);\n\n const fileStructure = getFileModelModulesFileStructure(modelName);\n\n // Batch process core files\n await Promise.all(\n Object.entries(fileStructure.core).map(async ([key, fileName]) => {\n const filePath = path.join(moduleDir, fileName);\n try {\n const module = await importModule(filePath).catch((err) => {\n if (!err.message.includes(\"Cannot find module\")) {\n console.error(`Failed to import ${fileName}: \\n`);\n console.error(err);\n killServerChildProcess();\n process.exit(1);\n }\n });\n\n if (module) {\n // Validate naming conventions before assignment\n validateNamingConventions(key, fileName, result);\n\n // Assign module to result\n assignModuleToResult(key, module, result);\n }\n } catch (err: any) {\n if (err.message.includes(\"Cannot use both\")) throw err;\n console.error(err);\n killServerChildProcess();\n }\n })\n );\n\n await Promise.all([\n processSubdir(modelName, \"dtos\", result),\n processSubdir(modelName, \"schemas\", result),\n ]);\n\n // Removed because caused problems with cached ZObjects\n // Cache the result making shallow copy to not cause problems after build\n // prismaModelsModules[modelName] = JSON.parse(JSON.stringify(result));\n prismaModelsModules[modelName] = result;\n\n return result;\n}\n\nexport type ModelFieldDefition = {\n name: string;\n type: string;\n isUnique: boolean;\n};\n\n/**\n * Represents the structure of relation fields for Prisma models.\n * It includes both singular (one-to-one) and list (one-to-many) relationships.\n *\n * @typedef {Object} RelationFields\n * @property {Array<{name: string, type: string}>} singular - List of singular relationships.\n * @property {Array<{name: string, type: string}>} list - List of list relationships.\n */\nexport type RelationFields = {\n singular: Omit<ModelFieldDefition, \"isUnique\">[];\n list: Omit<ModelFieldDefition, \"isUnique\">[];\n};\n\n/**\n * Reads the Prisma schema files and extracts all model definitions,\n * identifying their relations (one-to-one and one-to-many).\n */\nexport const prismaModelRelationFields: Record<string, RelationFields> = {};\n\nexport function getAllPrismaFiles(dirPath: string, fileList: string[] = []) {\n const files = fs.readdirSync(dirPath);\n\n files?.forEach((file) => {\n const filePath = path.join(dirPath, file);\n const stat = fs.statSync(filePath);\n\n // Skip migrations folder\n if (stat.isDirectory() && file !== \"migrations\") {\n fileList = getAllPrismaFiles(filePath, fileList);\n } else if (stat.isFile() && file.endsWith(\".prisma\")) {\n fileList.push(filePath);\n }\n });\n\n return fileList;\n}\n\nconst modelRegex = /model\\s+(\\w+)\\s*{/g;\nexport const models: string[] = [];\nexport let prismaSchemasContent: string;\nexport const prismaModelsUniqueFields: Record<string, ModelFieldDefition[]> =\n [] as any;\n\nexport function initializePrismaModels() {\n const prismaContent: string[] = [];\n\n const files = getAllPrismaFiles(\"./prisma\");\n\n for (const file of files) {\n const content = fs.readFileSync(file, \"utf-8\");\n\n if (!prismaContent?.includes?.(content)) prismaContent.push(content);\n }\n\n // Gather the content of all *.prisma files into single one\n const content = prismaContent\n .join(\"\\n\")\n .replace(modelRegex, (_, modelName) => {\n if (!models?.includes?.(modelName))\n models.push(camelCase(modelName.trim()));\n return `model ${modelName} {`;\n });\n\n const copiedContent = content;\n prismaSchemasContent = content;\n\n for (const model of models) {\n const modelName = pascalCase(model);\n\n const modelStart = copiedContent.indexOf(`model ${modelName} {`);\n const modelEnd = copiedContent.indexOf(\"}\", modelStart);\n const modelDefinition = copiedContent.slice(modelStart, modelEnd);\n\n const relations: RelationFields = {\n singular: [],\n list: [],\n };\n const lines = modelDefinition.split(\"\\n\");\n\n for (const line of lines) {\n const trimmedLine = line.trim();\n\n if (\n !trimmedLine ||\n trimmedLine.startsWith(\"model\") ||\n trimmedLine.startsWith(\"//\") ||\n trimmedLine.startsWith(\"/*\")\n )\n continue;\n\n const [fieldName, type] = trimmedLine.split(/\\s+/);\n const isUnique = trimmedLine?.includes?.(\"@unique\");\n\n if (isUnique) {\n const existingFields = prismaModelsUniqueFields[model] || [];\n\n const alreadyExists = existingFields.some(\n (field) =>\n field.name === fieldName &&\n field.type === type &&\n field.isUnique === isUnique\n );\n\n if (!alreadyExists) {\n prismaModelsUniqueFields[model] = [\n ...existingFields,\n { name: fieldName, type, isUnique },\n ];\n }\n }\n\n const cleanType = type?.replace(\"[]\", \"\").replace(\"?\", \"\");\n\n if (\n trimmedLine?.includes?.(\"@relation\") ||\n trimmedLine.match(/\\s+\\w+(\\[\\])?(\\s+@|$)/) ||\n models?.includes?.(camelCase(cleanType || \"\"))\n ) {\n const enumStart = copiedContent.indexOf(`enum ${cleanType} {`);\n const typeStart = copiedContent.indexOf(`type ${cleanType} {`);\n\n if (\n !cleanType ||\n enumStart >= 0 ||\n typeStart >= 0 ||\n cleanType === \"String\" ||\n cleanType === \"Int\" ||\n cleanType === \"Float\" ||\n cleanType === \"Boolean\" ||\n cleanType === \"DateTime\" ||\n cleanType === \"Bytes\" ||\n cleanType === \"Decimal\" ||\n cleanType === \"BigInt\" ||\n cleanType === \"Json\"\n ) {\n continue;\n }\n\n if (!type?.includes?.(\"[]\")) {\n relations.singular.push({\n name: fieldName,\n type: cleanType,\n });\n } else {\n relations.list.push({\n name: fieldName,\n type: cleanType,\n });\n }\n }\n\n prismaModelRelationFields[modelName] = relations;\n }\n }\n}\n\n// initializePrismaModels();\n\n/**\n * Retrieves the relations for a given Prisma model.\n *\n * @param {string} modelName - The name of the model (e.g., \"User\").\n * @returns {RelationFields|undefined} The relation fields for the model, or `undefined` if no relations are found.\n */\nexport function getPrismaModelRelations(\n modelName: string\n): RelationFields | undefined {\n modelName = pascalCase(modelName);\n\n if (!(modelName in prismaModelRelationFields)) return;\n return prismaModelRelationFields[modelName];\n}\n\n/**\n * Retrieves all the model names from the Prisma schema.\n *\n * @returns {string[]} An array of model names (e.g., [\"User\", \"Post\"]).\n */\nfunction getModels(): string[] {\n return models;\n}\n\n/**\n * Returns all content of all .prisma files gathered together\n *\n * @returns {string}\n */\nexport function getPrismaSchemasContent(): string {\n return prismaSchemasContent;\n}\n\n/** Retuns a given model unique fields\n * @param {string} modelName - The name of model in PascalCase\n * @returns {string[]} An array of all unique fields,\n */\nfunction getModelUniqueFields(modelName: string): ModelFieldDefition[] {\n return prismaModelsUniqueFields[modelName];\n}\n\nexport { getModels, getModelUniqueFields };\n"]}
package/dist/esm/app.js CHANGED
@@ -1 +1 @@
1
- "use strict";import c from"express";import p from"cors";import m from"cookie-parser";import{getAuthRouter as f}from"./modules/auth/auth.router.js";import{getPrismaModelsRouter as w,getAvailableResourcesAndRoutesRouter as R}from"./modules/base/base.router.js";import h from"./modules/error-handler/error-handler.controller.js";import{rateLimit as P}from"express-rate-limit";import y from"compression";import{handleRequestLogs as b}from"./modules/base/base.middlewares.js";import{checkDatabaseConnection as q,loadPrismaModule as A}from"./utils/helpers/prisma.helpers.js";import{getFileUploadRouter as O}from"./modules/file-upload/file-upload.router.js";import{queryParser as g}from"./utils/helpers/query-parser.helpers.js";import d from"./utils/helpers/deepmerge.helper.js";import{getSwaggerRouter as E}from"./modules/swagger/swagger.router.js";export const app=c();export async function bootstrap(e){await A(),e?.configureApp&&await e.configureApp(app);const n=e?.middlewares,t=n?.disable||[],a=n?.replace||{};t?.includes?.("compression")||app.use(a.compression||y(e?.compressionOptions)),t?.includes?.("global-rate-limit")||app.use(a.globalRateLimit||P(d({windowMs:60*1e3,limit:500,standardHeaders:"draft-7",legacyHeaders:!1,handler:(r,s)=>{s.status(429).json({message:"Too many requests, please try again later"})}},e?.globalRequestRateLimitOptions||{}))),t?.includes?.("cors")||app.use(a.cors||p(e?.cors?.customHandler?e.cors.customHandler:d({origin:(r,s)=>{const i=e?.cors?.allowedOrigins;i==="*"?s(null,!0):Array.isArray(i)?s(null,!r||i?.includes?.(r)):typeof i=="string"?s(null,!r||i===r):s(null,!1)},methods:["GET","POST","PUT","DELETE","PATCH","OPTIONS"],allowedHeaders:["Content-Type","Authorization","Connection"],credentials:!0},e?.cors?.options||{}))),t?.includes?.("express-json")||app.use(a.expressJson||c.json(e?.jsonBodyParserOptions)),t?.includes?.("cookie-parser")||app.use(a.cookieParser||m(...e?.cookieParserParameters||[])),t?.includes?.("query-parser")||app.use(a.queryParser||g(d({parseNull:!0,parseUndefined:!0,parseBoolean:!0},e?.queryParserOptions||{}))),t?.includes?.("database-connection")||app.use(a.databaseConnection||q),t?.includes?.("request-logger")||app.use(a.requestLogger||b),e?.middlewares?.additional&&e.middlewares.additional.forEach(r=>{app.use(r)});const l=e?.routers,u=l?.disable||[],o=l?.replace||{};if(u?.includes?.("welcome-endpoint")||app.get("/api",o.welcomeEndpoint||((r,s)=>{s.status(200).json({message:e.welcomeMessage})})),!u?.includes?.("file-upload")){const r=o.fileUpload?await o.fileUpload(e):await O(e);app.use(r)}if(!u?.includes?.("auth-router")&&e.authentication){const r=o.authRouter?await o.authRouter(e):await f(e);app.use("/api",r)}if(!u?.includes?.("prisma-models-router")){const r=o.prismaModelsRouter?await o.prismaModelsRouter(e):await w(e);app.use("/api",r)}return app.use("/api",R()),e.swagger&&(process.env.ARKOS_BUILD!=="true"||e.swagger.enableAfterBuild===!0)&&app.use("/api",await E(e)),l?.additional&&l.additional.forEach(r=>{app.use(r)}),t?.includes?.("global-error-handler")||app.use(a.globalErrorHandler||h),app.use("*",(r,s)=>{s.status(404).json({message:"Route not found!"})}),app}
1
+ "use strict";import c from"express";import p from"cors";import m from"cookie-parser";import{getAuthRouter as f}from"./modules/auth/auth.router";import{getPrismaModelsRouter as w,getAvailableResourcesAndRoutesRouter as R}from"./modules/base/base.router";import h from"./modules/error-handler/error-handler.controller";import{rateLimit as P}from"express-rate-limit";import y from"compression";import{handleRequestLogs as b}from"./modules/base/base.middlewares";import{checkDatabaseConnection as q,loadPrismaModule as A}from"./utils/helpers/prisma.helpers";import{getFileUploadRouter as O}from"./modules/file-upload/file-upload.router";import{queryParser as g}from"./utils/helpers/query-parser.helpers";import d from"./utils/helpers/deepmerge.helper";import{getSwaggerRouter as E}from"./modules/swagger/swagger.router";export const app=c();export async function bootstrap(e){await A(),e?.configureApp&&await e.configureApp(app);const n=e?.middlewares,t=n?.disable||[],a=n?.replace||{};t?.includes?.("compression")||app.use(a.compression||y(e?.compressionOptions)),t?.includes?.("global-rate-limit")||app.use(a.globalRateLimit||P(d({windowMs:60*1e3,limit:500,standardHeaders:"draft-7",legacyHeaders:!1,handler:(r,s)=>{s.status(429).json({message:"Too many requests, please try again later"})}},e?.globalRequestRateLimitOptions||{}))),t?.includes?.("cors")||app.use(a.cors||p(e?.cors?.customHandler?e.cors.customHandler:d({origin:(r,s)=>{const i=e?.cors?.allowedOrigins;i==="*"?s(null,!0):Array.isArray(i)?s(null,!r||i?.includes?.(r)):typeof i=="string"?s(null,!r||i===r):s(null,!1)},methods:["GET","POST","PUT","DELETE","PATCH","OPTIONS"],allowedHeaders:["Content-Type","Authorization","Connection"],credentials:!0},e?.cors?.options||{}))),t?.includes?.("express-json")||app.use(a.expressJson||c.json(e?.jsonBodyParserOptions)),t?.includes?.("cookie-parser")||app.use(a.cookieParser||m(...e?.cookieParserParameters||[])),t?.includes?.("query-parser")||app.use(a.queryParser||g(d({parseNull:!0,parseUndefined:!0,parseBoolean:!0},e?.queryParserOptions||{}))),t?.includes?.("database-connection")||app.use(a.databaseConnection||q),t?.includes?.("request-logger")||app.use(a.requestLogger||b),e?.middlewares?.additional&&e.middlewares.additional.forEach(r=>{app.use(r)});const l=e?.routers,u=l?.disable||[],o=l?.replace||{};if(u?.includes?.("welcome-endpoint")||app.get("/api",o.welcomeEndpoint||((r,s)=>{s.status(200).json({message:e.welcomeMessage})})),!u?.includes?.("file-upload")){const r=o.fileUpload?await o.fileUpload(e):await O(e);app.use(r)}if(!u?.includes?.("auth-router")&&e.authentication){const r=o.authRouter?await o.authRouter(e):await f(e);app.use("/api",r)}if(!u?.includes?.("prisma-models-router")){const r=o.prismaModelsRouter?await o.prismaModelsRouter(e):await w(e);app.use("/api",r)}return app.use("/api",R()),e.swagger&&(process.env.ARKOS_BUILD!=="true"||e.swagger.enableAfterBuild===!0)&&app.use("/api",await E(e)),l?.additional&&l.additional.forEach(r=>{app.use(r)}),t?.includes?.("global-error-handler")||app.use(a.globalErrorHandler||h),app.use("*",(r,s)=>{s.status(404).json({message:"Route not found!"})}),app}
@@ -1,2 +1,2 @@
1
- export { defaultExcludedUserFields } from "./../../modules/auth/auth.controller.js";
1
+ export { defaultExcludedUserFields } from "./../../modules/auth/auth.controller";
2
2
  //# sourceMappingURL=index.js.map