chore: refactor sessions

This commit is contained in:
David Nguyen
2025-02-16 00:44:01 +11:00
parent 8d5fafec27
commit 1ed1cb0773
21 changed files with 261 additions and 307 deletions

View File

@ -5,11 +5,8 @@ import { getSession } from '@documenso/auth/server/lib/utils/get-session';
import { ERROR_CODES } from './errors';
import { getServerLimits } from './server';
// res: NextApiResponse<TLimitsResponseSchema | TLimitsErrorResponseSchema>,
export const limitsHandler = async (req: Request) => {
try {
// Todo: Check
const { user } = await getSession(req);
const rawTeamId = req.headers.get('team-id');
@ -24,7 +21,7 @@ export const limitsHandler = async (req: Request) => {
throw new Error(ERROR_CODES.INVALID_TEAM_ID);
}
const limits = await getServerLimits({ email: user?.email, teamId });
const limits = await getServerLimits({ email: user.email, teamId });
return Response.json(limits, {
status: 200,

View File

@ -11,7 +11,7 @@ import type { TLimitsResponseSchema } from './schema';
import { ZLimitsSchema } from './schema';
export type GetServerLimitsOptions = {
email?: string | null;
email: string;
teamId?: number | null;
};