mirror of
https://github.com/documenso/documenso.git
synced 2025-11-14 16:51:38 +10:00
fix: refactor token router (#1981)
This commit is contained in:
27
packages/trpc/server/api-token-router/create-api-token.ts
Normal file
27
packages/trpc/server/api-token-router/create-api-token.ts
Normal 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,
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user