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,5 +1,4 @@
|
|
|
1
1
|
import { DMMF } from '@prisma/generator-helper'
|
|
2
|
-
import { toCamelCase } from '../utils/strings'
|
|
3
2
|
import { generateRouteConfigType } from './generateRouteConfigType'
|
|
4
3
|
import { ImportStyle } from '../utils/resolveImportStyle'
|
|
5
4
|
import { importExt } from '../utils/importExt'
|
|
@@ -17,9 +16,8 @@ export function generateFastifyRouterFunction({
|
|
|
17
16
|
}): string {
|
|
18
17
|
const ext = importExt(importStyle)
|
|
19
18
|
const modelName = model.name
|
|
20
|
-
const prefix = toCamelCase(modelName)
|
|
21
19
|
const modelNameLower = modelName.toLowerCase()
|
|
22
|
-
const routerFunctionName = `${
|
|
20
|
+
const routerFunctionName = `${modelName}Router`
|
|
23
21
|
|
|
24
22
|
const fieldsMeta = model.fields.map((f) => ({
|
|
25
23
|
name: f.name,
|
|
@@ -47,33 +45,33 @@ export function generateFastifyRouterFunction({
|
|
|
47
45
|
return `import type { FastifyInstance, FastifyRequest, FastifyReply, FastifyError } from 'fastify'
|
|
48
46
|
import { startQueryBuilder } from '../queryBuilder${ext}'
|
|
49
47
|
import {
|
|
50
|
-
${
|
|
51
|
-
${
|
|
52
|
-
${
|
|
53
|
-
${
|
|
54
|
-
${
|
|
55
|
-
${
|
|
56
|
-
${
|
|
57
|
-
${
|
|
58
|
-
${
|
|
59
|
-
${
|
|
60
|
-
${
|
|
61
|
-
${
|
|
62
|
-
${
|
|
63
|
-
${
|
|
64
|
-
${
|
|
65
|
-
${
|
|
66
|
-
${
|
|
67
|
-
${
|
|
48
|
+
${modelName}FindUnique,
|
|
49
|
+
${modelName}FindUniqueOrThrow,
|
|
50
|
+
${modelName}FindFirst,
|
|
51
|
+
${modelName}FindFirstOrThrow,
|
|
52
|
+
${modelName}FindMany,
|
|
53
|
+
${modelName}FindManyPaginated,
|
|
54
|
+
${modelName}Create,
|
|
55
|
+
${modelName}CreateMany,
|
|
56
|
+
${modelName}CreateManyAndReturn,
|
|
57
|
+
${modelName}Update,
|
|
58
|
+
${modelName}UpdateMany,
|
|
59
|
+
${modelName}UpdateManyAndReturn,
|
|
60
|
+
${modelName}Upsert,
|
|
61
|
+
${modelName}Delete,
|
|
62
|
+
${modelName}DeleteMany,
|
|
63
|
+
${modelName}Aggregate,
|
|
64
|
+
${modelName}Count,
|
|
65
|
+
${modelName}GroupBy,
|
|
68
66
|
} from './${modelName}Handlers${ext}'
|
|
69
67
|
import type { RouteConfig, FastifyHookHandler } from '../routeConfig.target${ext}'
|
|
70
68
|
import { parseQueryParams } from '../parseQueryParams${ext}'
|
|
71
|
-
import { sanitizeKeys } from '../misc${ext}'
|
|
69
|
+
import { sanitizeKeys, normalizePrefix, getEnv } from '../misc${ext}'
|
|
72
70
|
import { buildModelOpenApi } from '../buildModelOpenApi${ext}'
|
|
73
71
|
import { mapError, transformResult, HttpError, type OperationContext } from '../operationRuntime${ext}'
|
|
74
72
|
|
|
75
73
|
${generateRouteConfigType(modelName, 'FastifyHookHandler', guardShapesImport, importStyle, 'fastify')}
|
|
76
|
-
const _env =
|
|
74
|
+
const _env = getEnv()
|
|
77
75
|
|
|
78
76
|
const MODEL_FIELDS = ${JSON.stringify(fieldsMeta, null, 2)} as const
|
|
79
77
|
|
|
@@ -97,19 +95,10 @@ type FastifyExtended = FastifyRequest & {
|
|
|
97
95
|
resultStatus?: number
|
|
98
96
|
}
|
|
99
97
|
|
|
100
|
-
const defaultOpConfig: OperationConfigLike = {
|
|
101
|
-
before: [],
|
|
102
|
-
after: [],
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function normalizePrefix(p: string): string {
|
|
106
|
-
if (!p) return ''
|
|
107
|
-
let result = p
|
|
108
|
-
if (!result.startsWith('/')) result = '/' + result
|
|
109
|
-
while (result.length > 1 && result.endsWith('/')) result = result.slice(0, -1)
|
|
110
|
-
if (result === '/') return ''
|
|
111
|
-
return result
|
|
112
|
-
}
|
|
98
|
+
const defaultOpConfig: OperationConfigLike = Object.freeze({
|
|
99
|
+
before: Object.freeze([]) as unknown as FastifyHookHandler[],
|
|
100
|
+
after: Object.freeze([]) as unknown as FastifyHookHandler[],
|
|
101
|
+
})
|
|
113
102
|
|
|
114
103
|
function isQueryBuilderEnabled(config: RouteConfig): boolean {
|
|
115
104
|
if (config.queryBuilder === false) return false
|
|
@@ -149,16 +138,16 @@ function makeShapeHook(
|
|
|
149
138
|
if (paginationConfig) {
|
|
150
139
|
fx.routeConfig = { pagination: paginationConfig }
|
|
151
140
|
}
|
|
141
|
+
const headerName = (config.guard?.variantHeader || 'x-api-variant').toLowerCase()
|
|
142
|
+
const headerValue = request.headers[headerName]
|
|
143
|
+
const caller = config.guard?.resolveVariant?.(request)
|
|
144
|
+
?? (Array.isArray(headerValue) ? headerValue[0] : headerValue)
|
|
145
|
+
?? undefined
|
|
146
|
+
if (caller) {
|
|
147
|
+
fx.guardCaller = caller
|
|
148
|
+
}
|
|
152
149
|
if (opConfig.shape) {
|
|
153
150
|
fx.guardShape = opConfig.shape
|
|
154
|
-
const headerName = config.guard?.variantHeader || 'x-api-variant'
|
|
155
|
-
const headerValue = request.headers[headerName]
|
|
156
|
-
const caller = config.guard?.resolveVariant?.(request)
|
|
157
|
-
?? (Array.isArray(headerValue) ? headerValue[0] : headerValue)
|
|
158
|
-
?? undefined
|
|
159
|
-
if (caller) {
|
|
160
|
-
fx.guardCaller = caller
|
|
161
|
-
}
|
|
162
151
|
}
|
|
163
152
|
}
|
|
164
153
|
}
|
|
@@ -191,9 +180,9 @@ function sendError(reply: FastifyReply, error: unknown): void {
|
|
|
191
180
|
reply.code(httpError.status).send({ message: httpError.message })
|
|
192
181
|
}
|
|
193
182
|
|
|
194
|
-
export async function ${routerFunctionName}<TCtx = unknown>(
|
|
183
|
+
export async function ${routerFunctionName}<TCtx = unknown, TPrisma = any>(
|
|
195
184
|
fastify: FastifyInstance,
|
|
196
|
-
config: ${modelName}RouteConfig<TCtx> = {},
|
|
185
|
+
config: ${modelName}RouteConfig<TCtx, TPrisma> = {},
|
|
197
186
|
) {
|
|
198
187
|
const customPrefix = normalizePrefix(config.customUrlPrefix || '')
|
|
199
188
|
const modelPrefix = config.addModelPrefix !== false ? '/${modelNameLower}' : ''
|
|
@@ -207,6 +196,25 @@ export async function ${routerFunctionName}<TCtx = unknown>(
|
|
|
207
196
|
|
|
208
197
|
const postReadsEnabled = !config.disablePostReads
|
|
209
198
|
|
|
199
|
+
const openApiJsonSpec = openApiDisabled
|
|
200
|
+
? null
|
|
201
|
+
: buildModelOpenApi(
|
|
202
|
+
'${modelName}',
|
|
203
|
+
MODEL_FIELDS as unknown as Parameters<typeof buildModelOpenApi>[1],
|
|
204
|
+
MODEL_ENUMS as unknown as Parameters<typeof buildModelOpenApi>[2],
|
|
205
|
+
config,
|
|
206
|
+
{ format: 'json' },
|
|
207
|
+
)
|
|
208
|
+
const openApiYamlSpec = openApiDisabled
|
|
209
|
+
? null
|
|
210
|
+
: buildModelOpenApi(
|
|
211
|
+
'${modelName}',
|
|
212
|
+
MODEL_FIELDS as unknown as Parameters<typeof buildModelOpenApi>[1],
|
|
213
|
+
MODEL_ENUMS as unknown as Parameters<typeof buildModelOpenApi>[2],
|
|
214
|
+
config,
|
|
215
|
+
{ format: 'yaml' },
|
|
216
|
+
)
|
|
217
|
+
|
|
210
218
|
const qbEnabled = isQueryBuilderEnabled(config)
|
|
211
219
|
|
|
212
220
|
if (qbEnabled) {
|
|
@@ -234,25 +242,11 @@ export async function ${routerFunctionName}<TCtx = unknown>(
|
|
|
234
242
|
const openapiYamlPath = basePath ? \`\${basePath}/openapi.yaml\` : '/openapi.yaml'
|
|
235
243
|
|
|
236
244
|
fastify.get(openapiJsonPath, async (_request, reply) => {
|
|
237
|
-
|
|
238
|
-
'${modelName}',
|
|
239
|
-
MODEL_FIELDS as unknown as Parameters<typeof buildModelOpenApi>[1],
|
|
240
|
-
MODEL_ENUMS as unknown as Parameters<typeof buildModelOpenApi>[2],
|
|
241
|
-
config,
|
|
242
|
-
{ format: 'json' },
|
|
243
|
-
)
|
|
244
|
-
return reply.send(spec)
|
|
245
|
+
return reply.send(openApiJsonSpec)
|
|
245
246
|
})
|
|
246
247
|
|
|
247
248
|
fastify.get(openapiYamlPath, async (_request, reply) => {
|
|
248
|
-
|
|
249
|
-
'${modelName}',
|
|
250
|
-
MODEL_FIELDS as unknown as Parameters<typeof buildModelOpenApi>[1],
|
|
251
|
-
MODEL_ENUMS as unknown as Parameters<typeof buildModelOpenApi>[2],
|
|
252
|
-
config,
|
|
253
|
-
{ format: 'yaml' },
|
|
254
|
-
)
|
|
255
|
-
return reply.type('application/yaml').send(spec as string)
|
|
249
|
+
return reply.type('application/yaml').send(openApiYamlSpec as string)
|
|
256
250
|
})
|
|
257
251
|
}
|
|
258
252
|
|
|
@@ -293,121 +287,121 @@ export async function ${routerFunctionName}<TCtx = unknown>(
|
|
|
293
287
|
if (config.enableAll || config.findFirst) {
|
|
294
288
|
const opConfig: OperationConfigLike = (config.findFirst as OperationConfigLike | undefined) ?? defaultOpConfig
|
|
295
289
|
const path = basePath ? \`\${basePath}/first\` : '/first'
|
|
296
|
-
fastify.get(path, handleGet(opConfig, ${
|
|
297
|
-
if (postReadsEnabled) fastify.post(path, handleGet(opConfig, ${
|
|
290
|
+
fastify.get(path, handleGet(opConfig, ${modelName}FindFirst, parseQueryHook))
|
|
291
|
+
if (postReadsEnabled) fastify.post(path, handleGet(opConfig, ${modelName}FindFirst, parseBodyAsQueryHook))
|
|
298
292
|
}
|
|
299
293
|
|
|
300
294
|
if (config.enableAll || config.findFirstOrThrow) {
|
|
301
295
|
const opConfig: OperationConfigLike = (config.findFirstOrThrow as OperationConfigLike | undefined) ?? defaultOpConfig
|
|
302
296
|
const path = basePath ? \`\${basePath}/first/strict\` : '/first/strict'
|
|
303
|
-
fastify.get(path, handleGet(opConfig, ${
|
|
304
|
-
if (postReadsEnabled) fastify.post(path, handleGet(opConfig, ${
|
|
297
|
+
fastify.get(path, handleGet(opConfig, ${modelName}FindFirstOrThrow, parseQueryHook))
|
|
298
|
+
if (postReadsEnabled) fastify.post(path, handleGet(opConfig, ${modelName}FindFirstOrThrow, parseBodyAsQueryHook))
|
|
305
299
|
}
|
|
306
300
|
|
|
307
301
|
if (config.enableAll || config.findManyPaginated) {
|
|
308
302
|
const opConfig: OperationConfigLike = (config.findManyPaginated as OperationConfigLike | undefined) ?? defaultOpConfig
|
|
309
303
|
const path = basePath ? \`\${basePath}/paginated\` : '/paginated'
|
|
310
|
-
fastify.get(path, handleGet(opConfig, ${
|
|
311
|
-
if (postReadsEnabled) fastify.post(path, handleGet(opConfig, ${
|
|
304
|
+
fastify.get(path, handleGet(opConfig, ${modelName}FindManyPaginated, parseQueryHook))
|
|
305
|
+
if (postReadsEnabled) fastify.post(path, handleGet(opConfig, ${modelName}FindManyPaginated, parseBodyAsQueryHook))
|
|
312
306
|
}
|
|
313
307
|
|
|
314
308
|
if (config.enableAll || config.aggregate) {
|
|
315
309
|
const opConfig: OperationConfigLike = (config.aggregate as OperationConfigLike | undefined) ?? defaultOpConfig
|
|
316
310
|
const path = basePath ? \`\${basePath}/aggregate\` : '/aggregate'
|
|
317
|
-
fastify.get(path, handleGet(opConfig, ${
|
|
318
|
-
if (postReadsEnabled) fastify.post(path, handleGet(opConfig, ${
|
|
311
|
+
fastify.get(path, handleGet(opConfig, ${modelName}Aggregate, parseQueryHook))
|
|
312
|
+
if (postReadsEnabled) fastify.post(path, handleGet(opConfig, ${modelName}Aggregate, parseBodyAsQueryHook))
|
|
319
313
|
}
|
|
320
314
|
|
|
321
315
|
if (config.enableAll || config.count) {
|
|
322
316
|
const opConfig: OperationConfigLike = (config.count as OperationConfigLike | undefined) ?? defaultOpConfig
|
|
323
317
|
const path = basePath ? \`\${basePath}/count\` : '/count'
|
|
324
|
-
fastify.get(path, handleGet(opConfig, ${
|
|
325
|
-
if (postReadsEnabled) fastify.post(path, handleGet(opConfig, ${
|
|
318
|
+
fastify.get(path, handleGet(opConfig, ${modelName}Count, parseQueryHook))
|
|
319
|
+
if (postReadsEnabled) fastify.post(path, handleGet(opConfig, ${modelName}Count, parseBodyAsQueryHook))
|
|
326
320
|
}
|
|
327
321
|
|
|
328
322
|
if (config.enableAll || config.groupBy) {
|
|
329
323
|
const opConfig: OperationConfigLike = (config.groupBy as OperationConfigLike | undefined) ?? defaultOpConfig
|
|
330
324
|
const path = basePath ? \`\${basePath}/groupby\` : '/groupby'
|
|
331
|
-
fastify.get(path, handleGet(opConfig, ${
|
|
332
|
-
if (postReadsEnabled) fastify.post(path, handleGet(opConfig, ${
|
|
325
|
+
fastify.get(path, handleGet(opConfig, ${modelName}GroupBy, parseQueryHook))
|
|
326
|
+
if (postReadsEnabled) fastify.post(path, handleGet(opConfig, ${modelName}GroupBy, parseBodyAsQueryHook))
|
|
333
327
|
}
|
|
334
328
|
|
|
335
329
|
if (config.enableAll || config.findUniqueOrThrow) {
|
|
336
330
|
const opConfig: OperationConfigLike = (config.findUniqueOrThrow as OperationConfigLike | undefined) ?? defaultOpConfig
|
|
337
331
|
const path = basePath ? \`\${basePath}/unique/strict\` : '/unique/strict'
|
|
338
|
-
fastify.get(path, handleGet(opConfig, ${
|
|
339
|
-
if (postReadsEnabled) fastify.post(path, handleGet(opConfig, ${
|
|
332
|
+
fastify.get(path, handleGet(opConfig, ${modelName}FindUniqueOrThrow, parseQueryHook))
|
|
333
|
+
if (postReadsEnabled) fastify.post(path, handleGet(opConfig, ${modelName}FindUniqueOrThrow, parseBodyAsQueryHook))
|
|
340
334
|
}
|
|
341
335
|
|
|
342
336
|
if (config.enableAll || config.findUnique) {
|
|
343
337
|
const opConfig: OperationConfigLike = (config.findUnique as OperationConfigLike | undefined) ?? defaultOpConfig
|
|
344
338
|
const path = basePath ? \`\${basePath}/unique\` : '/unique'
|
|
345
|
-
fastify.get(path, handleGet(opConfig, ${
|
|
346
|
-
if (postReadsEnabled) fastify.post(path, handleGet(opConfig, ${
|
|
339
|
+
fastify.get(path, handleGet(opConfig, ${modelName}FindUnique, parseQueryHook))
|
|
340
|
+
if (postReadsEnabled) fastify.post(path, handleGet(opConfig, ${modelName}FindUnique, parseBodyAsQueryHook))
|
|
347
341
|
}
|
|
348
342
|
|
|
349
343
|
if (config.enableAll || config.findMany) {
|
|
350
344
|
const opConfig: OperationConfigLike = (config.findMany as OperationConfigLike | undefined) ?? defaultOpConfig
|
|
351
345
|
const path = basePath || '/'
|
|
352
|
-
fastify.get(path, handleGet(opConfig, ${
|
|
346
|
+
fastify.get(path, handleGet(opConfig, ${modelName}FindMany, parseQueryHook))
|
|
353
347
|
if (postReadsEnabled) {
|
|
354
348
|
const postPath = basePath ? \`\${basePath}/read\` : '/read'
|
|
355
|
-
fastify.post(postPath, handleGet(opConfig, ${
|
|
349
|
+
fastify.post(postPath, handleGet(opConfig, ${modelName}FindMany, parseBodyAsQueryHook))
|
|
356
350
|
}
|
|
357
351
|
}
|
|
358
352
|
|
|
359
353
|
if (config.enableAll || config.createManyAndReturn) {
|
|
360
354
|
const opConfig: OperationConfigLike = (config.createManyAndReturn as OperationConfigLike | undefined) ?? defaultOpConfig
|
|
361
355
|
const path = basePath ? \`\${basePath}/many/return\` : '/many/return'
|
|
362
|
-
fastify.post(path, handleWrite(opConfig, ${
|
|
356
|
+
fastify.post(path, handleWrite(opConfig, ${modelName}CreateManyAndReturn))
|
|
363
357
|
}
|
|
364
358
|
|
|
365
359
|
if (config.enableAll || config.createMany) {
|
|
366
360
|
const opConfig: OperationConfigLike = (config.createMany as OperationConfigLike | undefined) ?? defaultOpConfig
|
|
367
361
|
const path = basePath ? \`\${basePath}/many\` : '/many'
|
|
368
|
-
fastify.post(path, handleWrite(opConfig, ${
|
|
362
|
+
fastify.post(path, handleWrite(opConfig, ${modelName}CreateMany))
|
|
369
363
|
}
|
|
370
364
|
|
|
371
365
|
if (config.enableAll || config.create) {
|
|
372
366
|
const opConfig: OperationConfigLike = (config.create as OperationConfigLike | undefined) ?? defaultOpConfig
|
|
373
367
|
const path = basePath || '/'
|
|
374
|
-
fastify.post(path, handleWrite(opConfig, ${
|
|
368
|
+
fastify.post(path, handleWrite(opConfig, ${modelName}Create))
|
|
375
369
|
}
|
|
376
370
|
|
|
377
371
|
if (config.enableAll || config.updateManyAndReturn) {
|
|
378
372
|
const opConfig: OperationConfigLike = (config.updateManyAndReturn as OperationConfigLike | undefined) ?? defaultOpConfig
|
|
379
373
|
const path = basePath ? \`\${basePath}/many/return\` : '/many/return'
|
|
380
|
-
fastify.put(path, handleWrite(opConfig, ${
|
|
374
|
+
fastify.put(path, handleWrite(opConfig, ${modelName}UpdateManyAndReturn))
|
|
381
375
|
}
|
|
382
376
|
|
|
383
377
|
if (config.enableAll || config.updateMany) {
|
|
384
378
|
const opConfig: OperationConfigLike = (config.updateMany as OperationConfigLike | undefined) ?? defaultOpConfig
|
|
385
379
|
const path = basePath ? \`\${basePath}/many\` : '/many'
|
|
386
|
-
fastify.put(path, handleWrite(opConfig, ${
|
|
380
|
+
fastify.put(path, handleWrite(opConfig, ${modelName}UpdateMany))
|
|
387
381
|
}
|
|
388
382
|
|
|
389
383
|
if (config.enableAll || config.update) {
|
|
390
384
|
const opConfig: OperationConfigLike = (config.update as OperationConfigLike | undefined) ?? defaultOpConfig
|
|
391
385
|
const path = basePath || '/'
|
|
392
|
-
fastify.put(path, handleWrite(opConfig, ${
|
|
386
|
+
fastify.put(path, handleWrite(opConfig, ${modelName}Update))
|
|
393
387
|
}
|
|
394
388
|
|
|
395
389
|
if (config.enableAll || config.upsert) {
|
|
396
390
|
const opConfig: OperationConfigLike = (config.upsert as OperationConfigLike | undefined) ?? defaultOpConfig
|
|
397
391
|
const path = basePath || '/'
|
|
398
|
-
fastify.patch(path, handleWrite(opConfig, ${
|
|
392
|
+
fastify.patch(path, handleWrite(opConfig, ${modelName}Upsert))
|
|
399
393
|
}
|
|
400
394
|
|
|
401
395
|
if (config.enableAll || config.deleteMany) {
|
|
402
396
|
const opConfig: OperationConfigLike = (config.deleteMany as OperationConfigLike | undefined) ?? defaultOpConfig
|
|
403
397
|
const path = basePath ? \`\${basePath}/many\` : '/many'
|
|
404
|
-
fastify.delete(path, handleWrite(opConfig, ${
|
|
398
|
+
fastify.delete(path, handleWrite(opConfig, ${modelName}DeleteMany))
|
|
405
399
|
}
|
|
406
400
|
|
|
407
401
|
if (config.enableAll || config.delete) {
|
|
408
402
|
const opConfig: OperationConfigLike = (config.delete as OperationConfigLike | undefined) ?? defaultOpConfig
|
|
409
403
|
const path = basePath || '/'
|
|
410
|
-
fastify.delete(path, handleWrite(opConfig, ${
|
|
404
|
+
fastify.delete(path, handleWrite(opConfig, ${modelName}Delete))
|
|
411
405
|
}
|
|
412
406
|
}
|
|
413
407
|
`
|