feat: allow user to choose expiry date

This commit is contained in:
Catalin Pit
2024-02-09 11:32:54 +02:00
parent e91bb78f2d
commit b3ba77dfed
9 changed files with 140 additions and 26 deletions

View File

@ -46,10 +46,12 @@ export const apiTokenRouter = router({
.input(ZCreateTokenMutationSchema)
.mutation(async ({ input, ctx }) => {
try {
const { tokenName } = input;
const { tokenName, expirationDate } = input;
return await createApiToken({
userId: ctx.user.id,
tokenName,
expirationDate,
});
} catch (e) {
throw new TRPCError({

View File

@ -8,6 +8,7 @@ export type TGetApiTokenByIdQuerySchema = z.infer<typeof ZGetApiTokenByIdQuerySc
export const ZCreateTokenMutationSchema = z.object({
tokenName: z.string().min(3, { message: 'The token name should be 3 characters or longer' }),
expirationDate: z.string().nullable(),
});
export type TCreateTokenMutationSchema = z.infer<typeof ZCreateTokenMutationSchema>;