feat: adds tests for api keys endpoints

This commit is contained in:
Agusti Fernandez Pardo committed 2022-03-26 01:40:43 +01:00
1 parent 9e8be659c5
commit 12a7129e5a
10 files changed
+115 -20

No files matched your search

+1 -1
View File
@@ -3,7 +3,7 @@ import { z } from "zod";
const schemaApiKey = z
.object({
expiresAt: z.string().optional(), // default is 30 days
expiresAt: z.date().optional(), // default is 30 days
note: z.string().min(1).optional(),
})
.strict(); // Adding strict so that we can disallow passing in extra fields
+3 -3
View File
@@ -3,7 +3,7 @@ import { z } from "zod";
// Extracted out as utility function so can be reused
// at different endpoints that require this validation.
const schemaQueryId = z
const schemaQueryIdAsString = z
.object({
// since nextjs parses query params as strings,
// we need to cast them to numbers using z.transform() and parseInt()
@@ -12,9 +12,9 @@ const schemaQueryId = z
.strict();
const withValidQueryIdString = withValidation({
schema: schemaQueryId,
schema: schemaQueryIdAsString,
type: "Zod",
mode: "query",
});
export { schemaQueryId, withValidQueryIdString };
export { schemaQueryIdAsString, withValidQueryIdString };