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 +1 -1
- package/dist/helpers/generateFindFirst.js +1 -1
- package/dist/helpers/generateFindMany.js +1 -1
- package/dist/helpers/generateFindUnique.js +1 -1
- package/package.json +1 -1
- package/src/helpers/generateFindFirst.ts +1 -1
- package/src/helpers/generateFindMany.ts +1 -1
- package/src/helpers/generateFindUnique.ts +1 -1
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
|
|
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
|
|
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
|
|
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
|
|
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
|
@@ -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
|
|
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
|
|
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
|
|
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);
|