feat: adds tests for api keys endpoints
This commit is contained in:
1 parent
9e8be659c5
commit
12a7129e5a
10 files changed
+115
-20
No files matched your search
@@ -0,0 +1,3 @@
|
||||
export const stringifyISODate = (date: Date|undefined): string => {
|
||||
return `${date?.toISOString()}`
|
||||
}
|
||||
@@ -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,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 };
|
||||
Reference in new issue
Block a user