fix: refactor token router (#1981)

This commit is contained in:
David Nguyen
2025-08-25 08:25:01 +10:00
committed by GitHub
parent 49fabeb0ec
commit b8d07fd1a6
12 changed files with 122 additions and 69 deletions

View File

@ -0,0 +1,27 @@
import { createApiToken } from '@documenso/lib/server-only/public-api/create-api-token';
import { authenticatedProcedure } from '../trpc';
import {
ZCreateApiTokenRequestSchema,
ZCreateApiTokenResponseSchema,
} from './create-api-token.types';
export const createApiTokenRoute = authenticatedProcedure
.input(ZCreateApiTokenRequestSchema)
.output(ZCreateApiTokenResponseSchema)
.mutation(async ({ input, ctx }) => {
const { tokenName, teamId, expirationDate } = input;
ctx.logger.info({
input: {
teamId,
},
});
return await createApiToken({
userId: ctx.user.id,
teamId,
tokenName,
expiresIn: expirationDate,
});
});