prisma-generator-express 1.45.1 → 1.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/encodeQueryParams.js +4 -0
- package/dist/client/encodeQueryParams.js.map +1 -1
- package/dist/copy/misc.d.ts +4 -2
- package/dist/copy/misc.js +35 -24
- package/dist/copy/misc.js.map +1 -1
- package/dist/generators/generateFastifyHandler.js +2 -4
- package/dist/generators/generateFastifyHandler.js.map +1 -1
- package/dist/generators/generateHonoHandler.js +2 -4
- package/dist/generators/generateHonoHandler.js.map +1 -1
- package/dist/generators/generateImportPrismaStatement.d.ts +0 -1
- package/dist/generators/generateImportPrismaStatement.js +2 -20
- package/dist/generators/generateImportPrismaStatement.js.map +1 -1
- package/dist/generators/generateOperationCore.js +37 -1
- package/dist/generators/generateOperationCore.js.map +1 -1
- package/dist/generators/generateQueryBuilderHelper.js +9 -0
- package/dist/generators/generateQueryBuilderHelper.js.map +1 -1
- package/dist/generators/generateRelationMeta.js +0 -10
- package/dist/generators/generateRelationMeta.js.map +1 -1
- package/dist/generators/generateRouteConfigType.js +33 -12
- package/dist/generators/generateRouteConfigType.js.map +1 -1
- package/dist/generators/generateRouter.d.ts +0 -1
- package/dist/generators/generateRouter.js +96 -70
- package/dist/generators/generateRouter.js.map +1 -1
- package/dist/generators/generateRouterFastify.js +83 -89
- package/dist/generators/generateRouterFastify.js.map +1 -1
- package/dist/generators/generateRouterHono.js +257 -237
- package/dist/generators/generateRouterHono.js.map +1 -1
- package/dist/generators/generateUnifiedDocs.d.ts +2 -2
- package/dist/generators/generateUnifiedDocs.js +90 -252
- package/dist/generators/generateUnifiedDocs.js.map +1 -1
- package/dist/generators/generateUnifiedHandler.js +2 -4
- package/dist/generators/generateUnifiedHandler.js.map +1 -1
- package/dist/index.js +16 -8
- package/dist/index.js.map +1 -1
- package/dist/utils/copyFiles.js +3 -2
- package/dist/utils/copyFiles.js.map +1 -1
- package/dist/utils/strings.d.ts +0 -1
- package/dist/utils/strings.js +0 -9
- package/dist/utils/strings.js.map +1 -1
- package/package.json +1 -1
- package/src/client/encodeQueryParams.ts +7 -15
- package/src/copy/autoIncludePlanner.ts +4 -17
- package/src/copy/autoIncludeRuntime.ts +11 -19
- package/src/copy/buildModelOpenApi.ts +11 -14
- package/src/copy/docsRenderer.ts +8 -14
- package/src/copy/misc.ts +28 -23
- package/src/copy/operationRuntime.ts +61 -43
- package/src/copy/parseQueryParams.ts +5 -14
- package/src/copy/routeConfig.express.ts +24 -18
- package/src/copy/routeConfig.fastify.ts +1 -1
- package/src/copy/routeConfig.hono.ts +34 -6
- package/src/copy/routeConfig.ts +3 -2
- package/src/generators/generateFastifyHandler.ts +2 -5
- package/src/generators/generateHonoHandler.ts +2 -5
- package/src/generators/generateImportPrismaStatement.ts +3 -35
- package/src/generators/generateOperationCore.ts +37 -1
- package/src/generators/generateQueryBuilderHelper.ts +9 -0
- package/src/generators/generateRelationMeta.ts +0 -10
- package/src/generators/generateRouteConfigType.ts +34 -10
- package/src/generators/generateRouter.ts +96 -71
- package/src/generators/generateRouterFastify.ts +83 -89
- package/src/generators/generateRouterHono.ts +257 -237
- package/src/generators/generateUnifiedDocs.ts +89 -267
- package/src/generators/generateUnifiedHandler.ts +2 -4
- package/src/index.ts +45 -14
- package/src/utils/copyFiles.ts +2 -2
- package/src/utils/strings.ts +0 -8
- package/src/copy/createOutputValidatorMiddleware.ts +0 -47
- package/src/copy/createValidatorMiddleware.ts +0 -62
- package/src/copy/transformZod.ts +0 -139
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateFastifyRouterFunction = generateFastifyRouterFunction;
|
|
4
|
-
const strings_1 = require("../utils/strings");
|
|
5
4
|
const generateRouteConfigType_1 = require("./generateRouteConfigType");
|
|
6
5
|
const importExt_1 = require("../utils/importExt");
|
|
7
6
|
function generateFastifyRouterFunction({ model, enums, guardShapesImport, importStyle, }) {
|
|
8
7
|
const ext = (0, importExt_1.importExt)(importStyle);
|
|
9
8
|
const modelName = model.name;
|
|
10
|
-
const prefix = (0, strings_1.toCamelCase)(modelName);
|
|
11
9
|
const modelNameLower = modelName.toLowerCase();
|
|
12
|
-
const routerFunctionName = `${
|
|
10
|
+
const routerFunctionName = `${modelName}Router`;
|
|
13
11
|
const fieldsMeta = model.fields.map((f) => ({
|
|
14
12
|
name: f.name,
|
|
15
13
|
kind: f.kind,
|
|
@@ -31,33 +29,33 @@ function generateFastifyRouterFunction({ model, enums, guardShapesImport, import
|
|
|
31
29
|
return `import type { FastifyInstance, FastifyRequest, FastifyReply, FastifyError } from 'fastify'
|
|
32
30
|
import { startQueryBuilder } from '../queryBuilder${ext}'
|
|
33
31
|
import {
|
|
34
|
-
${
|
|
35
|
-
${
|
|
36
|
-
${
|
|
37
|
-
${
|
|
38
|
-
${
|
|
39
|
-
${
|
|
40
|
-
${
|
|
41
|
-
${
|
|
42
|
-
${
|
|
43
|
-
${
|
|
44
|
-
${
|
|
45
|
-
${
|
|
46
|
-
${
|
|
47
|
-
${
|
|
48
|
-
${
|
|
49
|
-
${
|
|
50
|
-
${
|
|
51
|
-
${
|
|
32
|
+
${modelName}FindUnique,
|
|
33
|
+
${modelName}FindUniqueOrThrow,
|
|
34
|
+
${modelName}FindFirst,
|
|
35
|
+
${modelName}FindFirstOrThrow,
|
|
36
|
+
${modelName}FindMany,
|
|
37
|
+
${modelName}FindManyPaginated,
|
|
38
|
+
${modelName}Create,
|
|
39
|
+
${modelName}CreateMany,
|
|
40
|
+
${modelName}CreateManyAndReturn,
|
|
41
|
+
${modelName}Update,
|
|
42
|
+
${modelName}UpdateMany,
|
|
43
|
+
${modelName}UpdateManyAndReturn,
|
|
44
|
+
${modelName}Upsert,
|
|
45
|
+
${modelName}Delete,
|
|
46
|
+
${modelName}DeleteMany,
|
|
47
|
+
${modelName}Aggregate,
|
|
48
|
+
${modelName}Count,
|
|
49
|
+
${modelName}GroupBy,
|
|
52
50
|
} from './${modelName}Handlers${ext}'
|
|
53
51
|
import type { RouteConfig, FastifyHookHandler } from '../routeConfig.target${ext}'
|
|
54
52
|
import { parseQueryParams } from '../parseQueryParams${ext}'
|
|
55
|
-
import { sanitizeKeys } from '../misc${ext}'
|
|
53
|
+
import { sanitizeKeys, normalizePrefix, getEnv } from '../misc${ext}'
|
|
56
54
|
import { buildModelOpenApi } from '../buildModelOpenApi${ext}'
|
|
57
55
|
import { mapError, transformResult, HttpError, type OperationContext } from '../operationRuntime${ext}'
|
|
58
56
|
|
|
59
57
|
${(0, generateRouteConfigType_1.generateRouteConfigType)(modelName, 'FastifyHookHandler', guardShapesImport, importStyle, 'fastify')}
|
|
60
|
-
const _env =
|
|
58
|
+
const _env = getEnv()
|
|
61
59
|
|
|
62
60
|
const MODEL_FIELDS = ${JSON.stringify(fieldsMeta, null, 2)} as const
|
|
63
61
|
|
|
@@ -81,19 +79,10 @@ type FastifyExtended = FastifyRequest & {
|
|
|
81
79
|
resultStatus?: number
|
|
82
80
|
}
|
|
83
81
|
|
|
84
|
-
const defaultOpConfig: OperationConfigLike = {
|
|
85
|
-
before: [],
|
|
86
|
-
after: [],
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function normalizePrefix(p: string): string {
|
|
90
|
-
if (!p) return ''
|
|
91
|
-
let result = p
|
|
92
|
-
if (!result.startsWith('/')) result = '/' + result
|
|
93
|
-
while (result.length > 1 && result.endsWith('/')) result = result.slice(0, -1)
|
|
94
|
-
if (result === '/') return ''
|
|
95
|
-
return result
|
|
96
|
-
}
|
|
82
|
+
const defaultOpConfig: OperationConfigLike = Object.freeze({
|
|
83
|
+
before: Object.freeze([]) as unknown as FastifyHookHandler[],
|
|
84
|
+
after: Object.freeze([]) as unknown as FastifyHookHandler[],
|
|
85
|
+
})
|
|
97
86
|
|
|
98
87
|
function isQueryBuilderEnabled(config: RouteConfig): boolean {
|
|
99
88
|
if (config.queryBuilder === false) return false
|
|
@@ -133,16 +122,16 @@ function makeShapeHook(
|
|
|
133
122
|
if (paginationConfig) {
|
|
134
123
|
fx.routeConfig = { pagination: paginationConfig }
|
|
135
124
|
}
|
|
125
|
+
const headerName = (config.guard?.variantHeader || 'x-api-variant').toLowerCase()
|
|
126
|
+
const headerValue = request.headers[headerName]
|
|
127
|
+
const caller = config.guard?.resolveVariant?.(request)
|
|
128
|
+
?? (Array.isArray(headerValue) ? headerValue[0] : headerValue)
|
|
129
|
+
?? undefined
|
|
130
|
+
if (caller) {
|
|
131
|
+
fx.guardCaller = caller
|
|
132
|
+
}
|
|
136
133
|
if (opConfig.shape) {
|
|
137
134
|
fx.guardShape = opConfig.shape
|
|
138
|
-
const headerName = config.guard?.variantHeader || 'x-api-variant'
|
|
139
|
-
const headerValue = request.headers[headerName]
|
|
140
|
-
const caller = config.guard?.resolveVariant?.(request)
|
|
141
|
-
?? (Array.isArray(headerValue) ? headerValue[0] : headerValue)
|
|
142
|
-
?? undefined
|
|
143
|
-
if (caller) {
|
|
144
|
-
fx.guardCaller = caller
|
|
145
|
-
}
|
|
146
135
|
}
|
|
147
136
|
}
|
|
148
137
|
}
|
|
@@ -175,9 +164,9 @@ function sendError(reply: FastifyReply, error: unknown): void {
|
|
|
175
164
|
reply.code(httpError.status).send({ message: httpError.message })
|
|
176
165
|
}
|
|
177
166
|
|
|
178
|
-
export async function ${routerFunctionName}<TCtx = unknown>(
|
|
167
|
+
export async function ${routerFunctionName}<TCtx = unknown, TPrisma = any>(
|
|
179
168
|
fastify: FastifyInstance,
|
|
180
|
-
config: ${modelName}RouteConfig<TCtx> = {},
|
|
169
|
+
config: ${modelName}RouteConfig<TCtx, TPrisma> = {},
|
|
181
170
|
) {
|
|
182
171
|
const customPrefix = normalizePrefix(config.customUrlPrefix || '')
|
|
183
172
|
const modelPrefix = config.addModelPrefix !== false ? '/${modelNameLower}' : ''
|
|
@@ -191,6 +180,25 @@ export async function ${routerFunctionName}<TCtx = unknown>(
|
|
|
191
180
|
|
|
192
181
|
const postReadsEnabled = !config.disablePostReads
|
|
193
182
|
|
|
183
|
+
const openApiJsonSpec = openApiDisabled
|
|
184
|
+
? null
|
|
185
|
+
: buildModelOpenApi(
|
|
186
|
+
'${modelName}',
|
|
187
|
+
MODEL_FIELDS as unknown as Parameters<typeof buildModelOpenApi>[1],
|
|
188
|
+
MODEL_ENUMS as unknown as Parameters<typeof buildModelOpenApi>[2],
|
|
189
|
+
config,
|
|
190
|
+
{ format: 'json' },
|
|
191
|
+
)
|
|
192
|
+
const openApiYamlSpec = openApiDisabled
|
|
193
|
+
? null
|
|
194
|
+
: buildModelOpenApi(
|
|
195
|
+
'${modelName}',
|
|
196
|
+
MODEL_FIELDS as unknown as Parameters<typeof buildModelOpenApi>[1],
|
|
197
|
+
MODEL_ENUMS as unknown as Parameters<typeof buildModelOpenApi>[2],
|
|
198
|
+
config,
|
|
199
|
+
{ format: 'yaml' },
|
|
200
|
+
)
|
|
201
|
+
|
|
194
202
|
const qbEnabled = isQueryBuilderEnabled(config)
|
|
195
203
|
|
|
196
204
|
if (qbEnabled) {
|
|
@@ -218,25 +226,11 @@ export async function ${routerFunctionName}<TCtx = unknown>(
|
|
|
218
226
|
const openapiYamlPath = basePath ? \`\${basePath}/openapi.yaml\` : '/openapi.yaml'
|
|
219
227
|
|
|
220
228
|
fastify.get(openapiJsonPath, async (_request, reply) => {
|
|
221
|
-
|
|
222
|
-
'${modelName}',
|
|
223
|
-
MODEL_FIELDS as unknown as Parameters<typeof buildModelOpenApi>[1],
|
|
224
|
-
MODEL_ENUMS as unknown as Parameters<typeof buildModelOpenApi>[2],
|
|
225
|
-
config,
|
|
226
|
-
{ format: 'json' },
|
|
227
|
-
)
|
|
228
|
-
return reply.send(spec)
|
|
229
|
+
return reply.send(openApiJsonSpec)
|
|
229
230
|
})
|
|
230
231
|
|
|
231
232
|
fastify.get(openapiYamlPath, async (_request, reply) => {
|
|
232
|
-
|
|
233
|
-
'${modelName}',
|
|
234
|
-
MODEL_FIELDS as unknown as Parameters<typeof buildModelOpenApi>[1],
|
|
235
|
-
MODEL_ENUMS as unknown as Parameters<typeof buildModelOpenApi>[2],
|
|
236
|
-
config,
|
|
237
|
-
{ format: 'yaml' },
|
|
238
|
-
)
|
|
239
|
-
return reply.type('application/yaml').send(spec as string)
|
|
233
|
+
return reply.type('application/yaml').send(openApiYamlSpec as string)
|
|
240
234
|
})
|
|
241
235
|
}
|
|
242
236
|
|
|
@@ -277,121 +271,121 @@ export async function ${routerFunctionName}<TCtx = unknown>(
|
|
|
277
271
|
if (config.enableAll || config.findFirst) {
|
|
278
272
|
const opConfig: OperationConfigLike = (config.findFirst as OperationConfigLike | undefined) ?? defaultOpConfig
|
|
279
273
|
const path = basePath ? \`\${basePath}/first\` : '/first'
|
|
280
|
-
fastify.get(path, handleGet(opConfig, ${
|
|
281
|
-
if (postReadsEnabled) fastify.post(path, handleGet(opConfig, ${
|
|
274
|
+
fastify.get(path, handleGet(opConfig, ${modelName}FindFirst, parseQueryHook))
|
|
275
|
+
if (postReadsEnabled) fastify.post(path, handleGet(opConfig, ${modelName}FindFirst, parseBodyAsQueryHook))
|
|
282
276
|
}
|
|
283
277
|
|
|
284
278
|
if (config.enableAll || config.findFirstOrThrow) {
|
|
285
279
|
const opConfig: OperationConfigLike = (config.findFirstOrThrow as OperationConfigLike | undefined) ?? defaultOpConfig
|
|
286
280
|
const path = basePath ? \`\${basePath}/first/strict\` : '/first/strict'
|
|
287
|
-
fastify.get(path, handleGet(opConfig, ${
|
|
288
|
-
if (postReadsEnabled) fastify.post(path, handleGet(opConfig, ${
|
|
281
|
+
fastify.get(path, handleGet(opConfig, ${modelName}FindFirstOrThrow, parseQueryHook))
|
|
282
|
+
if (postReadsEnabled) fastify.post(path, handleGet(opConfig, ${modelName}FindFirstOrThrow, parseBodyAsQueryHook))
|
|
289
283
|
}
|
|
290
284
|
|
|
291
285
|
if (config.enableAll || config.findManyPaginated) {
|
|
292
286
|
const opConfig: OperationConfigLike = (config.findManyPaginated as OperationConfigLike | undefined) ?? defaultOpConfig
|
|
293
287
|
const path = basePath ? \`\${basePath}/paginated\` : '/paginated'
|
|
294
|
-
fastify.get(path, handleGet(opConfig, ${
|
|
295
|
-
if (postReadsEnabled) fastify.post(path, handleGet(opConfig, ${
|
|
288
|
+
fastify.get(path, handleGet(opConfig, ${modelName}FindManyPaginated, parseQueryHook))
|
|
289
|
+
if (postReadsEnabled) fastify.post(path, handleGet(opConfig, ${modelName}FindManyPaginated, parseBodyAsQueryHook))
|
|
296
290
|
}
|
|
297
291
|
|
|
298
292
|
if (config.enableAll || config.aggregate) {
|
|
299
293
|
const opConfig: OperationConfigLike = (config.aggregate as OperationConfigLike | undefined) ?? defaultOpConfig
|
|
300
294
|
const path = basePath ? \`\${basePath}/aggregate\` : '/aggregate'
|
|
301
|
-
fastify.get(path, handleGet(opConfig, ${
|
|
302
|
-
if (postReadsEnabled) fastify.post(path, handleGet(opConfig, ${
|
|
295
|
+
fastify.get(path, handleGet(opConfig, ${modelName}Aggregate, parseQueryHook))
|
|
296
|
+
if (postReadsEnabled) fastify.post(path, handleGet(opConfig, ${modelName}Aggregate, parseBodyAsQueryHook))
|
|
303
297
|
}
|
|
304
298
|
|
|
305
299
|
if (config.enableAll || config.count) {
|
|
306
300
|
const opConfig: OperationConfigLike = (config.count as OperationConfigLike | undefined) ?? defaultOpConfig
|
|
307
301
|
const path = basePath ? \`\${basePath}/count\` : '/count'
|
|
308
|
-
fastify.get(path, handleGet(opConfig, ${
|
|
309
|
-
if (postReadsEnabled) fastify.post(path, handleGet(opConfig, ${
|
|
302
|
+
fastify.get(path, handleGet(opConfig, ${modelName}Count, parseQueryHook))
|
|
303
|
+
if (postReadsEnabled) fastify.post(path, handleGet(opConfig, ${modelName}Count, parseBodyAsQueryHook))
|
|
310
304
|
}
|
|
311
305
|
|
|
312
306
|
if (config.enableAll || config.groupBy) {
|
|
313
307
|
const opConfig: OperationConfigLike = (config.groupBy as OperationConfigLike | undefined) ?? defaultOpConfig
|
|
314
308
|
const path = basePath ? \`\${basePath}/groupby\` : '/groupby'
|
|
315
|
-
fastify.get(path, handleGet(opConfig, ${
|
|
316
|
-
if (postReadsEnabled) fastify.post(path, handleGet(opConfig, ${
|
|
309
|
+
fastify.get(path, handleGet(opConfig, ${modelName}GroupBy, parseQueryHook))
|
|
310
|
+
if (postReadsEnabled) fastify.post(path, handleGet(opConfig, ${modelName}GroupBy, parseBodyAsQueryHook))
|
|
317
311
|
}
|
|
318
312
|
|
|
319
313
|
if (config.enableAll || config.findUniqueOrThrow) {
|
|
320
314
|
const opConfig: OperationConfigLike = (config.findUniqueOrThrow as OperationConfigLike | undefined) ?? defaultOpConfig
|
|
321
315
|
const path = basePath ? \`\${basePath}/unique/strict\` : '/unique/strict'
|
|
322
|
-
fastify.get(path, handleGet(opConfig, ${
|
|
323
|
-
if (postReadsEnabled) fastify.post(path, handleGet(opConfig, ${
|
|
316
|
+
fastify.get(path, handleGet(opConfig, ${modelName}FindUniqueOrThrow, parseQueryHook))
|
|
317
|
+
if (postReadsEnabled) fastify.post(path, handleGet(opConfig, ${modelName}FindUniqueOrThrow, parseBodyAsQueryHook))
|
|
324
318
|
}
|
|
325
319
|
|
|
326
320
|
if (config.enableAll || config.findUnique) {
|
|
327
321
|
const opConfig: OperationConfigLike = (config.findUnique as OperationConfigLike | undefined) ?? defaultOpConfig
|
|
328
322
|
const path = basePath ? \`\${basePath}/unique\` : '/unique'
|
|
329
|
-
fastify.get(path, handleGet(opConfig, ${
|
|
330
|
-
if (postReadsEnabled) fastify.post(path, handleGet(opConfig, ${
|
|
323
|
+
fastify.get(path, handleGet(opConfig, ${modelName}FindUnique, parseQueryHook))
|
|
324
|
+
if (postReadsEnabled) fastify.post(path, handleGet(opConfig, ${modelName}FindUnique, parseBodyAsQueryHook))
|
|
331
325
|
}
|
|
332
326
|
|
|
333
327
|
if (config.enableAll || config.findMany) {
|
|
334
328
|
const opConfig: OperationConfigLike = (config.findMany as OperationConfigLike | undefined) ?? defaultOpConfig
|
|
335
329
|
const path = basePath || '/'
|
|
336
|
-
fastify.get(path, handleGet(opConfig, ${
|
|
330
|
+
fastify.get(path, handleGet(opConfig, ${modelName}FindMany, parseQueryHook))
|
|
337
331
|
if (postReadsEnabled) {
|
|
338
332
|
const postPath = basePath ? \`\${basePath}/read\` : '/read'
|
|
339
|
-
fastify.post(postPath, handleGet(opConfig, ${
|
|
333
|
+
fastify.post(postPath, handleGet(opConfig, ${modelName}FindMany, parseBodyAsQueryHook))
|
|
340
334
|
}
|
|
341
335
|
}
|
|
342
336
|
|
|
343
337
|
if (config.enableAll || config.createManyAndReturn) {
|
|
344
338
|
const opConfig: OperationConfigLike = (config.createManyAndReturn as OperationConfigLike | undefined) ?? defaultOpConfig
|
|
345
339
|
const path = basePath ? \`\${basePath}/many/return\` : '/many/return'
|
|
346
|
-
fastify.post(path, handleWrite(opConfig, ${
|
|
340
|
+
fastify.post(path, handleWrite(opConfig, ${modelName}CreateManyAndReturn))
|
|
347
341
|
}
|
|
348
342
|
|
|
349
343
|
if (config.enableAll || config.createMany) {
|
|
350
344
|
const opConfig: OperationConfigLike = (config.createMany as OperationConfigLike | undefined) ?? defaultOpConfig
|
|
351
345
|
const path = basePath ? \`\${basePath}/many\` : '/many'
|
|
352
|
-
fastify.post(path, handleWrite(opConfig, ${
|
|
346
|
+
fastify.post(path, handleWrite(opConfig, ${modelName}CreateMany))
|
|
353
347
|
}
|
|
354
348
|
|
|
355
349
|
if (config.enableAll || config.create) {
|
|
356
350
|
const opConfig: OperationConfigLike = (config.create as OperationConfigLike | undefined) ?? defaultOpConfig
|
|
357
351
|
const path = basePath || '/'
|
|
358
|
-
fastify.post(path, handleWrite(opConfig, ${
|
|
352
|
+
fastify.post(path, handleWrite(opConfig, ${modelName}Create))
|
|
359
353
|
}
|
|
360
354
|
|
|
361
355
|
if (config.enableAll || config.updateManyAndReturn) {
|
|
362
356
|
const opConfig: OperationConfigLike = (config.updateManyAndReturn as OperationConfigLike | undefined) ?? defaultOpConfig
|
|
363
357
|
const path = basePath ? \`\${basePath}/many/return\` : '/many/return'
|
|
364
|
-
fastify.put(path, handleWrite(opConfig, ${
|
|
358
|
+
fastify.put(path, handleWrite(opConfig, ${modelName}UpdateManyAndReturn))
|
|
365
359
|
}
|
|
366
360
|
|
|
367
361
|
if (config.enableAll || config.updateMany) {
|
|
368
362
|
const opConfig: OperationConfigLike = (config.updateMany as OperationConfigLike | undefined) ?? defaultOpConfig
|
|
369
363
|
const path = basePath ? \`\${basePath}/many\` : '/many'
|
|
370
|
-
fastify.put(path, handleWrite(opConfig, ${
|
|
364
|
+
fastify.put(path, handleWrite(opConfig, ${modelName}UpdateMany))
|
|
371
365
|
}
|
|
372
366
|
|
|
373
367
|
if (config.enableAll || config.update) {
|
|
374
368
|
const opConfig: OperationConfigLike = (config.update as OperationConfigLike | undefined) ?? defaultOpConfig
|
|
375
369
|
const path = basePath || '/'
|
|
376
|
-
fastify.put(path, handleWrite(opConfig, ${
|
|
370
|
+
fastify.put(path, handleWrite(opConfig, ${modelName}Update))
|
|
377
371
|
}
|
|
378
372
|
|
|
379
373
|
if (config.enableAll || config.upsert) {
|
|
380
374
|
const opConfig: OperationConfigLike = (config.upsert as OperationConfigLike | undefined) ?? defaultOpConfig
|
|
381
375
|
const path = basePath || '/'
|
|
382
|
-
fastify.patch(path, handleWrite(opConfig, ${
|
|
376
|
+
fastify.patch(path, handleWrite(opConfig, ${modelName}Upsert))
|
|
383
377
|
}
|
|
384
378
|
|
|
385
379
|
if (config.enableAll || config.deleteMany) {
|
|
386
380
|
const opConfig: OperationConfigLike = (config.deleteMany as OperationConfigLike | undefined) ?? defaultOpConfig
|
|
387
381
|
const path = basePath ? \`\${basePath}/many\` : '/many'
|
|
388
|
-
fastify.delete(path, handleWrite(opConfig, ${
|
|
382
|
+
fastify.delete(path, handleWrite(opConfig, ${modelName}DeleteMany))
|
|
389
383
|
}
|
|
390
384
|
|
|
391
385
|
if (config.enableAll || config.delete) {
|
|
392
386
|
const opConfig: OperationConfigLike = (config.delete as OperationConfigLike | undefined) ?? defaultOpConfig
|
|
393
387
|
const path = basePath || '/'
|
|
394
|
-
fastify.delete(path, handleWrite(opConfig, ${
|
|
388
|
+
fastify.delete(path, handleWrite(opConfig, ${modelName}Delete))
|
|
395
389
|
}
|
|
396
390
|
}
|
|
397
391
|
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateRouterFastify.js","sourceRoot":"","sources":["../../src/generators/generateRouterFastify.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"generateRouterFastify.js","sourceRoot":"","sources":["../../src/generators/generateRouterFastify.ts"],"names":[],"mappings":";;AAKA,sEAkZC;AAtZD,uEAAmE;AAEnE,kDAA8C;AAE9C,SAAgB,6BAA6B,CAAC,EAC5C,KAAK,EACL,KAAK,EACL,iBAAiB,EACjB,WAAW,GAMZ;IACC,MAAM,GAAG,GAAG,IAAA,qBAAS,EAAC,WAAW,CAAC,CAAA;IAClC,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAA;IAC5B,MAAM,cAAc,GAAG,SAAS,CAAC,WAAW,EAAE,CAAA;IAC9C,MAAM,kBAAkB,GAAG,GAAG,SAAS,QAAQ,CAAA;IAE/C,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC1C,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,MAAM,EAAE,CAAC,CAAC,MAAM;QAChB,UAAU,EAAE,CAAC,CAAC,UAAU;QACxB,eAAe,EAAE,CAAC,CAAC,eAAe;QAClC,WAAW,EAAE,CAAC,CAAC,WAAW,IAAI,KAAK;QACnC,aAAa,EAAE,CAAC,CAAC,aAAa;QAC9B,kBAAkB,EAAE,CAAC,CAAC,kBAAkB;KACzC,CAAC,CAAC,CAAA;IAEH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