Skip to content

Commit

Permalink
add contract and schema for email update request
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeh committed Oct 12, 2024
1 parent d91005c commit fc28cfa
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions shared/contracts/users.contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { UpdateUserDto } from "@shared/dtos/users/update-user.dto";

import { ApiResponse } from "@shared/dtos/global/api-response.dto";
import { UpdateUserPasswordSchema } from "@shared/schemas/users/update-password.schema";
import { RequestEmailUpdateSchema } from "@shared/schemas/users/request-email-update.schema";

const contract = initContract();
export const usersContract = contract.router({
Expand Down Expand Up @@ -39,6 +40,14 @@ export const usersContract = contract.router({
body: UpdateUserPasswordSchema,
summary: "Update password of the user",
},
updateEmail: {
method: "PATCH",
path: "/users/me/email",
responses: {
200: contract.type<null>(),
},
body: RequestEmailUpdateSchema,
},
deleteMe: {
method: "DELETE",
path: "/users/me",
Expand Down
4 changes: 4 additions & 0 deletions shared/dtos/users/request-email-update.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { z } from "zod";
import { RequestEmailUpdateSchema } from "@shared/schemas/users/request-email-update.schema";

export type RequestEmailUpdateDto = z.infer<typeof RequestEmailUpdateSchema>;
6 changes: 6 additions & 0 deletions shared/schemas/users/request-email-update.schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { z } from "zod";

export const RequestEmailUpdateSchema = z.object({
email: z.string().email(),
newEmail: z.string().email(),
});

0 comments on commit fc28cfa

Please sign in to comment.