diff --git a/packages/backend/src/domain/ErrorLogDomain.ts b/packages/backend/src/domain/ErrorLogDomain.ts index 19697da8..f132b15f 100644 --- a/packages/backend/src/domain/ErrorLogDomain.ts +++ b/packages/backend/src/domain/ErrorLogDomain.ts @@ -2,52 +2,52 @@ import { AbstractDomain, makeDomain } from "@internal"; import mongoose from "mongoose"; import z from "zod"; -export const errorLogDomain = makeDomain( - class extends AbstractDomain { - zod = z - .object({ - details: z.string().min(0).openapi({ - example: "Request body validation error", - }), - status: z.number().openapi({ - example: 400, - }), - message: z.string().openapi({ - example: - "The server cannot or will not process the request due to an apparent client error.", - }), - path: z.string().openapi({ - example: "/auth/login", - }), - timestamp: z.string().openapi({ - example: "2024-01-01T00:00:00.000Z", +export class ErrorLogDomain extends AbstractDomain { + zod = z + .object({ + details: z.string().min(0).openapi({ + example: "Request body validation error", + }), + status: z.number().openapi({ + example: 400, + }), + message: z.string().openapi({ + example: + "The server cannot or will not process the request due to an apparent client error.", + }), + path: z.string().openapi({ + example: "/auth/login", + }), + timestamp: z.string().openapi({ + example: "2024-01-01T00:00:00.000Z", + }), + metadata: z + .record(z.string(), z.any()) + + .openapi({ + example: { + errors: [ + "[password] String must contain at least 1 character(s)", + "[username] String must contain at least 1 character(s)", + ], + }, }), - metadata: z - .record(z.string(), z.any()) + }) + .describe("ErrorLog"); - .openapi({ - example: { - errors: [ - "[password] String must contain at least 1 character(s)", - "[username] String must contain at least 1 character(s)", - ], - }, - }), - }) - .describe("ErrorLog"); + schema = new mongoose.Schema>( + { + details: { type: String, required: true }, + status: { type: Number, required: true }, + message: { type: String, required: true }, + path: { type: String, required: true }, + timestamp: { type: String, required: true }, + metadata: { type: Object }, + }, + { capped: 2048 }, + ); +} - schema = new mongoose.Schema>( - { - details: { type: String, required: true }, - status: { type: Number, required: true }, - message: { type: String, required: true }, - path: { type: String, required: true }, - timestamp: { type: String, required: true }, - metadata: { type: Object }, - }, - { capped: 2048 }, - ); - }, -); +export const errorLogDomain = makeDomain(ErrorLogDomain); export type ErrorLog = z.infer<(typeof errorLogDomain)["zod"]>; diff --git a/packages/backend/src/domain/UserDomain.ts b/packages/backend/src/domain/UserDomain.ts index 9da1744f..dfc277cf 100644 --- a/packages/backend/src/domain/UserDomain.ts +++ b/packages/backend/src/domain/UserDomain.ts @@ -3,26 +3,26 @@ import { Role } from "@org/shared"; import mongoose from "mongoose"; import z from "zod"; -export const userDomain = makeDomain( - class extends AbstractDomain { - zod = z - .object({ - username: z.string().openapi({ example: "john_doe" }), - password: z.string().openapi({ example: "password" }), - email: z.string().email().openapi({ example: "john.doe@mail.com" }), - roles: z.array(Role).openapi({ example: [Role.enum.USER, Role.enum.ADMIN] }), - refreshToken: z.array(z.string()), - }) - .describe("User"); +export class UserDomain extends AbstractDomain { + zod = z + .object({ + username: z.string().openapi({ example: "john_doe" }), + password: z.string().openapi({ example: "password" }), + email: z.string().email().openapi({ example: "john.doe@mail.com" }), + roles: z.array(Role).openapi({ example: [Role.enum.USER, Role.enum.ADMIN] }), + refreshToken: z.array(z.string()), + }) + .describe("User"); - schema = new mongoose.Schema>({ - username: { type: String, required: true }, - password: { type: String, required: true }, - email: { type: String, required: true }, - roles: { type: [String], required: true }, - refreshToken: { type: [String] }, - }); - }, -); + schema = new mongoose.Schema>({ + username: { type: String, required: true }, + password: { type: String, required: true }, + email: { type: String, required: true }, + roles: { type: [String], required: true }, + refreshToken: { type: [String] }, + }); +} + +export const userDomain = makeDomain(UserDomain); export type User = z.infer<(typeof userDomain)["zod"]>; diff --git a/packages/backend/src/index.ts b/packages/backend/src/index.ts index b58829b2..6accff11 100644 --- a/packages/backend/src/index.ts +++ b/packages/backend/src/index.ts @@ -4,20 +4,4 @@ import "@types"; -import "./config/zod/environment"; - -import "./decorators/config/bottlejs"; - -import "./config/logger"; - -import "./infrastructure/middleware/globals/index"; - -import "./infrastructure/repository/impl/UserRepositoryImpl"; - -import "./infrastructure/service/impl/UserServiceImpl"; - -import "./web/controllers/AuthController"; - -import "./web/controllers/UserController"; - export * from "./internal";