From 6f32ce9397c520eb339e54079dc51a2908aa9911 Mon Sep 17 00:00:00 2001 From: alexeh Date: Fri, 11 Oct 2024 06:38:04 +0200 Subject: [PATCH] Add router base conf --- shared/contracts/index.ts | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/shared/contracts/index.ts b/shared/contracts/index.ts index f90acfbf..4321f1be 100644 --- a/shared/contracts/index.ts +++ b/shared/contracts/index.ts @@ -2,11 +2,29 @@ import { initContract } from "@ts-rest/core"; import { adminContract } from "@shared/contracts/admin.contract"; import { authContract } from "@shared/contracts/auth.contract"; import { usersContract } from "@shared/contracts/users.contract"; +import { JSONAPIError } from "@shared/dtos/json-api.error"; const contract = initContract(); -export const router = contract.router({ - auth: authContract, - admin: adminContract, - user: usersContract, -}); +export const router = contract.router( + { + auth: authContract, + admin: adminContract, + user: usersContract, + }, + { + commonResponses: { + 400: contract.type(), + 401: contract.type(), + 403: contract.type(), + 404: contract.type(), + 500: contract.type(), + }, + strictStatusCodes: true, + }, +); + +const baseRouterConfig = contract.router( + { authContract, adminContract, usersContract }, + {}, +);