mirror of
https://github.com/documenso/documenso.git
synced 2025-11-14 08:42:12 +10:00
28 lines
696 B
TypeScript
28 lines
696 B
TypeScript
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,
|
|
});
|
|
});
|