mirror of
https://github.com/hanzoai/sign.git
synced 2026-10-21 01:21:51 +00:00
The product is branded Hanzo eSign (esign.hanzo.ai, repo hanzoai/esign). Rename all workspace packages @hanzo/sign-* → @hanzo/esign-* (1052 files) and align docker/Dockerfile turbo --scope/--filter to the actual remix package name @hanzo/esign (was a pre-existing mismatch with -remix that broke the build). Protected deps (@hanzo/insights, @hanzo/logo) untouched.
35 lines
1.4 KiB
TypeScript
35 lines
1.4 KiB
TypeScript
// esign ZAP handlers — api-token router (fully ported, 3/3 procedures).
|
|
//
|
|
// Verbatim tRPC procedure bodies rewired to (ctx, input). Routes:
|
|
// apiToken.create / apiToken.getMany / apiToken.delete.
|
|
import { createApiToken } from '@hanzo/esign-lib/server-only/public-api/create-api-token';
|
|
import { deleteTokenById } from '@hanzo/esign-lib/server-only/public-api/delete-api-token-by-id';
|
|
import { getApiTokens } from '@hanzo/esign-lib/server-only/public-api/get-api-tokens';
|
|
|
|
import { ZCreateApiTokenRequestSchema } from '../../../server/api-token-router/create-api-token.types';
|
|
import { ZDeleteApiTokenRequestSchema } from '../../../server/api-token-router/delete-api-token.types';
|
|
import type { ZapContext } from '../context';
|
|
import type { ZapRouteMap } from '../dispatch';
|
|
|
|
export const apiTokenRoutes: ZapRouteMap = {
|
|
'apiToken.create': async (ctx: ZapContext, raw) => {
|
|
const { tokenName, teamId, expirationDate } = ZCreateApiTokenRequestSchema.parse(raw);
|
|
return await createApiToken({
|
|
userId: ctx.user.id,
|
|
teamId,
|
|
tokenName,
|
|
expiresIn: expirationDate,
|
|
});
|
|
},
|
|
|
|
'apiToken.getMany': async (ctx: ZapContext) => {
|
|
return await getApiTokens({ userId: ctx.user.id, teamId: ctx.teamId });
|
|
},
|
|
|
|
'apiToken.delete': async (ctx: ZapContext, raw) => {
|
|
const { id, teamId } = ZDeleteApiTokenRequestSchema.parse(raw);
|
|
await deleteTokenById({ id, teamId, userId: ctx.user.id });
|
|
return undefined;
|
|
},
|
|
};
|