prisma-generator-express 1.16.2 → 1.16.3
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.
|
@@ -21,7 +21,7 @@ import { ${modelName}DeleteMany } from './${modelName}DeleteMany';
|
|
|
21
21
|
import { ${modelName}Aggregate } from './${modelName}Aggregate';
|
|
22
22
|
import { ${modelName}Count } from './${modelName}Count';
|
|
23
23
|
import { ${modelName}GroupBy } from './${modelName}GroupBy';
|
|
24
|
-
import { createValidatorMiddleware } from '../createValidatorMiddleware'
|
|
24
|
+
import { createValidatorMiddleware, sanitizePrefix } from '../createValidatorMiddleware'
|
|
25
25
|
import { RouteConfig, ValidatorConfig } from '../routeConfig'
|
|
26
26
|
import { parseQueryParams } from "../parseQueryParams";
|
|
27
27
|
|
|
@@ -40,7 +40,8 @@ const defaultBeforeAfter = {
|
|
|
40
40
|
*/
|
|
41
41
|
export function ${routerFunctionName}(config: RouteConfig<RequestHandler>) {
|
|
42
42
|
const router = express.Router();
|
|
43
|
-
const basePath = (config.customUrlPrefix || '') +
|
|
43
|
+
const basePath = sanitizePrefix(config.customUrlPrefix || '') +
|
|
44
|
+
sanitizePrefix(config.addModelPrefix !== false ? '/${modelName.toLowerCase()}' : '');
|
|
44
45
|
|
|
45
46
|
const setupRoute = (
|
|
46
47
|
path: string,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateRouteFile.js","sourceRoot":"","sources":["../../src/helpers/generateRouteFile.ts"],"names":[],"mappings":";;;AAEA,SAAgB,sBAAsB,CAAC,EACrC,KAAK,GAGN;IACC,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAA;IAC5B,MAAM,kBAAkB,GAAG,GAAG,SAAS,QAAQ,CAAA;IAE/C,OAAO;;;;WAIE,SAAS,uBAAuB,SAAS;WACzC,SAAS,sBAAsB,SAAS;WACxC,SAAS,wBAAwB,SAAS;WAC1C,SAAS,oBAAoB,SAAS;WACtC,SAAS,wBAA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P,SAAS;;;;;;;;0CAQb,SAAS;;;;;;;;4CAQP,SAAS;;;;;;;;CAQpD,CAAA;AACD,CAAC;AAhMD,wDAgMC"}
|
package/package.json
CHANGED
|
@@ -30,7 +30,13 @@ export function createOutputValidatorMiddleware({
|
|
|
30
30
|
const validationResult = schema.safeParse(data)
|
|
31
31
|
if (!validationResult.success) {
|
|
32
32
|
const errors = validationResult.error.errors
|
|
33
|
-
|
|
33
|
+
next({
|
|
34
|
+
status: 400,
|
|
35
|
+
message: 'Output validation failed',
|
|
36
|
+
errors,
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
return res.status(400).json({
|
|
34
40
|
status: 400,
|
|
35
41
|
message: 'Output validation failed',
|
|
36
42
|
errors,
|
|
@@ -25,7 +25,7 @@ import { ${modelName}DeleteMany } from './${modelName}DeleteMany';
|
|
|
25
25
|
import { ${modelName}Aggregate } from './${modelName}Aggregate';
|
|
26
26
|
import { ${modelName}Count } from './${modelName}Count';
|
|
27
27
|
import { ${modelName}GroupBy } from './${modelName}GroupBy';
|
|
28
|
-
import { createValidatorMiddleware } from '../createValidatorMiddleware'
|
|
28
|
+
import { createValidatorMiddleware, sanitizePrefix } from '../createValidatorMiddleware'
|
|
29
29
|
import { RouteConfig, ValidatorConfig } from '../routeConfig'
|
|
30
30
|
import { parseQueryParams } from "../parseQueryParams";
|
|
31
31
|
|
|
@@ -44,7 +44,8 @@ const defaultBeforeAfter = {
|
|
|
44
44
|
*/
|
|
45
45
|
export function ${routerFunctionName}(config: RouteConfig<RequestHandler>) {
|
|
46
46
|
const router = express.Router();
|
|
47
|
-
const basePath = (config.customUrlPrefix || '') +
|
|
47
|
+
const basePath = sanitizePrefix(config.customUrlPrefix || '') +
|
|
48
|
+
sanitizePrefix(config.addModelPrefix !== false ? '/${modelName.toLowerCase()}' : '');
|
|
48
49
|
|
|
49
50
|
const setupRoute = (
|
|
50
51
|
path: string,
|