Skip to content

Commit

Permalink
fix(shared): Add more reponse codes in the http contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
alepefe committed Nov 8, 2024
1 parent 4b170b6 commit 30f556b
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions shared/contracts/auth.contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const authContract = contract.router({
201: contract.type<null>(),
400: contract.type<JSONAPIError>(),
409: contract.type<JSONAPIError>(),
500: contract.type<JSONAPIError>(),
},
body: SignUpSchema,
},
Expand All @@ -25,6 +26,7 @@ export const authContract = contract.router({
responses: {
201: contract.type<IAccessToken>(),
401: contract.type<JSONAPIError>(),
500: contract.type<JSONAPIError>(),
},
body: SignInSchema,
},
Expand All @@ -34,6 +36,7 @@ export const authContract = contract.router({
responses: {
200: null,
400: contract.type<JSONAPIError>(),
500: contract.type<JSONAPIError>(),
},
body: EmailSchema,
},
Expand Down
1 change: 1 addition & 0 deletions shared/contracts/contact.contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const contactContract = contract.router({
responses: {
201: contract.type<null>(),
400: contract.type<JSONAPIError>(),
500: contract.type<JSONAPIError>(),
},
body: ContactUsSchema,
},
Expand Down
1 change: 1 addition & 0 deletions shared/contracts/page-filters.contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const pageFiltersContract = contract.router({
responses: {
200: contract.type<ApiResponse<PageFilter[]>>(),
400: contract.type<JSONAPIError>(),
500: contract.type<JSONAPIError>(),
},
},
});
1 change: 1 addition & 0 deletions shared/contracts/sections.contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const sectionContract = contract.router({
responses: {
200: contract.type<ApiPaginationResponse<SectionWithDataWidget>>(),
400: contract.type<JSONAPIError>(),
500: contract.type<JSONAPIError>(),
},
},
});
20 changes: 20 additions & 0 deletions shared/contracts/users.contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const usersContract = contract.router({
responses: {
201: contract.type<ApiResponse<UserDto>>(),
400: contract.type<{ message: string }>(),
500: contract.type<JSONAPIError>(),
},
body: contract.type<CreateUserDto>(),
summary: 'Create a new user',
Expand All @@ -36,6 +37,7 @@ export const usersContract = contract.router({
responses: {
200: contract.type<ApiPaginationResponse<UserDto>>(),
400: contract.type<{ message: string }>(),
500: contract.type<JSONAPIError>(),
},
summary: 'Get all users',
query: generateEntityQuerySchema(User),
Expand All @@ -46,6 +48,7 @@ export const usersContract = contract.router({
responses: {
200: contract.type<ApiResponse<UserDto>>(),
401: contract.type<JSONAPIError>(),
500: contract.type<JSONAPIError>(),
},
query: generateEntityQuerySchema(User),
},
Expand All @@ -56,6 +59,8 @@ export const usersContract = contract.router({
200: contract.type<ApiResponse<UserDto>>(),
400: contract.type<JSONAPIError>(),
401: contract.type<JSONAPIError>(),
404: contract.type<JSONAPIError>(),
500: contract.type<JSONAPIError>(),
},
body: contract.type<UpdateUserPasswordDto>(),
summary: 'Update password of the user',
Expand All @@ -70,6 +75,8 @@ export const usersContract = contract.router({
200: contract.type<UserDto>(),
400: contract.type<JSONAPIError>(),
401: contract.type<JSONAPIError>(),
404: contract.type<JSONAPIError>(),
500: contract.type<JSONAPIError>(),
},
query: generateEntityQuerySchema(User),
summary: 'Get a user by id',
Expand All @@ -84,6 +91,8 @@ export const usersContract = contract.router({
200: contract.type<ApiResponse<UserDto>>(),
400: contract.type<JSONAPIError>(),
401: contract.type<JSONAPIError>(),
404: contract.type<JSONAPIError>(),
500: contract.type<JSONAPIError>(),
},
body: contract.type<UpdateUserDto>(),
summary: 'Update an existing user',
Expand All @@ -95,6 +104,7 @@ export const usersContract = contract.router({
200: null,
400: contract.type<JSONAPIError>(),
401: contract.type<JSONAPIError>(),
500: contract.type<JSONAPIError>(),
},
body: null,
},
Expand All @@ -104,6 +114,7 @@ export const usersContract = contract.router({
responses: {
200: contract.type<null>(),
400: contract.type<JSONAPIError>(),
500: contract.type<JSONAPIError>(),
},
body: PasswordSchema,
},
Expand All @@ -116,6 +127,8 @@ export const usersContract = contract.router({
responses: {
200: contract.type<ApiPaginationResponse<CustomWidget>>(),
400: contract.type<JSONAPIError>(),
404: contract.type<JSONAPIError>(),
500: contract.type<JSONAPIError>(),
},
},
findCustomWidget: {
Expand All @@ -125,6 +138,8 @@ export const usersContract = contract.router({
responses: {
200: contract.type<ApiResponse<CustomWidget>>(),
400: contract.type<JSONAPIError>(),
404: contract.type<JSONAPIError>(),
500: contract.type<JSONAPIError>(),
},
},
createCustomWidget: {
Expand All @@ -135,6 +150,7 @@ export const usersContract = contract.router({
responses: {
201: contract.type<ApiResponse<CustomWidget>>(),
400: contract.type<JSONAPIError>(),
500: contract.type<JSONAPIError>(),
},
},
updateCustomWidget: {
Expand All @@ -145,6 +161,8 @@ export const usersContract = contract.router({
responses: {
200: contract.type<ApiResponse<CustomWidget>>(),
400: contract.type<JSONAPIError>(),
404: contract.type<JSONAPIError>(),
500: contract.type<JSONAPIError>(),
},
},
deleteCustomWidget: {
Expand All @@ -155,6 +173,8 @@ export const usersContract = contract.router({
responses: {
200: contract.type<ApiResponse<CustomWidget>>(),
400: contract.type<JSONAPIError>(),
404: contract.type<JSONAPIError>(),
500: contract.type<JSONAPIError>(),
},
},
});

0 comments on commit 30f556b

Please sign in to comment.