From fc28cfac5abce6202e50847666169f39e2c51039 Mon Sep 17 00:00:00 2001 From: alexeh Date: Sat, 12 Oct 2024 10:41:52 +0200 Subject: [PATCH] add contract and schema for email update request --- shared/contracts/users.contract.ts | 9 +++++++++ shared/dtos/users/request-email-update.dto.ts | 4 ++++ shared/schemas/users/request-email-update.schema.ts | 6 ++++++ 3 files changed, 19 insertions(+) create mode 100644 shared/dtos/users/request-email-update.dto.ts create mode 100644 shared/schemas/users/request-email-update.schema.ts diff --git a/shared/contracts/users.contract.ts b/shared/contracts/users.contract.ts index 511a00cb..a17236c6 100644 --- a/shared/contracts/users.contract.ts +++ b/shared/contracts/users.contract.ts @@ -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({ @@ -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(), + }, + body: RequestEmailUpdateSchema, + }, deleteMe: { method: "DELETE", path: "/users/me", diff --git a/shared/dtos/users/request-email-update.dto.ts b/shared/dtos/users/request-email-update.dto.ts new file mode 100644 index 00000000..69840d15 --- /dev/null +++ b/shared/dtos/users/request-email-update.dto.ts @@ -0,0 +1,4 @@ +import { z } from "zod"; +import { RequestEmailUpdateSchema } from "@shared/schemas/users/request-email-update.schema"; + +export type RequestEmailUpdateDto = z.infer; diff --git a/shared/schemas/users/request-email-update.schema.ts b/shared/schemas/users/request-email-update.schema.ts new file mode 100644 index 00000000..46d2b007 --- /dev/null +++ b/shared/schemas/users/request-email-update.schema.ts @@ -0,0 +1,6 @@ +import { z } from "zod"; + +export const RequestEmailUpdateSchema = z.object({ + email: z.string().email(), + newEmail: z.string().email(), +});