prisma-generator-express 1.7.0 → 1.7.1

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/README.md CHANGED
@@ -156,7 +156,7 @@ The following properties can be attached to the `req` object to control the beha
156
156
  | Property | Type | Description |
157
157
  | ---------------------- | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
158
158
  | `prisma` | PrismaClient | An instance of PrismaClient that allows the middleware to interact with your database. |
159
- | `passToNext` | boolean | Optional, if `true` - the result of a Prisma request will be passed to a next middleware as `req.locals?.data` |
159
+ | `passToNext` | boolean | Optional, if `true` - the result of a Prisma request will be passed to a next middleware as `if (req.locals) req.locals.data` |
160
160
  | `query` | Object | A structured object that conforms to Prisma's API for the selected method. |
161
161
  | `outputValidation` | ZodTypeAny | (Optional) A Zod schema used to validate the data returned from the Prisma query before sending it to the client. This helps ensure the response adheres to expected data formats. |
162
162
  | `omitOutputValidation` | Boolean | (Optional) A flag that, if set to `true`, disables output validation even if a Zod schema is provided. |
@@ -37,7 +37,7 @@ export async function ${functionName}(req: FindFirstRequest, res: Response, next
37
37
 
38
38
  const data = await req.prisma.${(0, strings_1.lowercaseFirstLetter)(modelName)}.findFirst(req.query as ${queryTypeName});
39
39
  if (req.passToNext) {
40
- req.locals?.data = data;
40
+ if (req.locals) req.locals.data = data;
41
41
  next();
42
42
  } else if (!req.omitOutputValidation && req.outputValidation) {
43
43
  const validationResult = req.outputValidation.safeParse(data);
@@ -37,7 +37,7 @@ export async function ${functionName}(req: FindManyRequest, res: Response, next:
37
37
 
38
38
  const data = await req.prisma.${(0, strings_1.lowercaseFirstLetter)(modelName)}.findMany(req.query as ${queryTypeName});
39
39
  if (req.passToNext) {
40
- req.locals?.data = data;
40
+ if (req.locals) req.locals.data = data;
41
41
  next();
42
42
  } else if (!req.omitOutputValidation && req.outputValidation) {
43
43
  const validationResult = req.outputValidation.safeParse(data);
@@ -37,7 +37,7 @@ export async function ${functionName}(req: FindUniqueRequest, res: Response, nex
37
37
 
38
38
  const data = await req.prisma.${(0, strings_1.lowercaseFirstLetter)(modelName)}.findUnique(req.query as ${queryTypeName});
39
39
  if (req.passToNext) {
40
- req.locals?.data = data;
40
+ if (req.locals) req.locals.data = data;
41
41
  next();
42
42
  } else if (!req.omitOutputValidation && req.outputValidation) {
43
43
  const validationResult = req.outputValidation.safeParse(data);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "prisma-generator-express",
3
3
  "description": "Prisma generator of Express CRUD API",
4
- "version": "1.7.0",
4
+ "version": "1.7.1",
5
5
  "main": "dist/generator.js",
6
6
  "license": "MIT",
7
7
  "bin": {
@@ -45,7 +45,7 @@ export async function ${functionName}(req: FindFirstRequest, res: Response, next
45
45
 
46
46
  const data = await req.prisma.${lowercaseFirstLetter(modelName)}.findFirst(req.query as ${queryTypeName});
47
47
  if (req.passToNext) {
48
- req.locals?.data = data;
48
+ if (req.locals) req.locals.data = data;
49
49
  next();
50
50
  } else if (!req.omitOutputValidation && req.outputValidation) {
51
51
  const validationResult = req.outputValidation.safeParse(data);
@@ -45,7 +45,7 @@ export async function ${functionName}(req: FindManyRequest, res: Response, next:
45
45
 
46
46
  const data = await req.prisma.${lowercaseFirstLetter(modelName)}.findMany(req.query as ${queryTypeName});
47
47
  if (req.passToNext) {
48
- req.locals?.data = data;
48
+ if (req.locals) req.locals.data = data;
49
49
  next();
50
50
  } else if (!req.omitOutputValidation && req.outputValidation) {
51
51
  const validationResult = req.outputValidation.safeParse(data);
@@ -45,7 +45,7 @@ export async function ${functionName}(req: FindUniqueRequest, res: Response, nex
45
45
 
46
46
  const data = await req.prisma.${lowercaseFirstLetter(modelName)}.findUnique(req.query as ${queryTypeName});
47
47
  if (req.passToNext) {
48
- req.locals?.data = data;
48
+ if (req.locals) req.locals.data = data;
49
49
  next();
50
50
  } else if (!req.omitOutputValidation && req.outputValidation) {
51
51
  const validationResult = req.outputValidation.safeParse(data);