From b514e69fd5e60a5b1fb7141b7b989e29ff241c4d Mon Sep 17 00:00:00 2001 From: Victor Gomes Date: Fri, 27 Sep 2024 13:32:56 -0400 Subject: [PATCH] =?UTF-8?q?Fix:=20correct=20middleware=20place=20?= =?UTF-8?q?=F0=9F=AA=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/entity.controller.ts | 2 +- src/controllers/middlewares/index.ts | 1 - src/controllers/user.controller.ts | 2 +- src/{controllers => }/middlewares/SchemaValidation.ts | 2 +- src/middlewares/index.ts | 1 + 5 files changed, 4 insertions(+), 4 deletions(-) delete mode 100644 src/controllers/middlewares/index.ts rename src/{controllers => }/middlewares/SchemaValidation.ts (88%) diff --git a/src/controllers/entity.controller.ts b/src/controllers/entity.controller.ts index aae4e88..c7a7e48 100644 --- a/src/controllers/entity.controller.ts +++ b/src/controllers/entity.controller.ts @@ -1,7 +1,7 @@ import { Router, Request, Response } from "express"; import ApiCache from 'apicache' import BaseController from "./base-controller"; -import { ValidateSchema } from "./middlewares"; +import { ValidateSchema } from "../middlewares"; import { Guard } from "../middlewares"; import { EntityService } from "../services/entity.service"; import { LogService } from "../services/log.service"; diff --git a/src/controllers/middlewares/index.ts b/src/controllers/middlewares/index.ts deleted file mode 100644 index 537084f..0000000 --- a/src/controllers/middlewares/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { ValidateSchema } from './SchemaValidation' diff --git a/src/controllers/user.controller.ts b/src/controllers/user.controller.ts index 586379f..1b47891 100644 --- a/src/controllers/user.controller.ts +++ b/src/controllers/user.controller.ts @@ -1,7 +1,7 @@ import { Request, Response, Router } from "express"; import BaseController from "./base-controller"; import { Guard } from "../middlewares"; -import { ValidateSchema } from "./middlewares"; +import { ValidateSchema } from "../middlewares"; import { User, UserModel } from "../models/"; import { UserService } from "../services/user.service"; import { idSchema, parsedIdSchema } from "../schemas/global.schema"; diff --git a/src/controllers/middlewares/SchemaValidation.ts b/src/middlewares/SchemaValidation.ts similarity index 88% rename from src/controllers/middlewares/SchemaValidation.ts rename to src/middlewares/SchemaValidation.ts index 2339809..43a8ea5 100644 --- a/src/controllers/middlewares/SchemaValidation.ts +++ b/src/middlewares/SchemaValidation.ts @@ -1,6 +1,6 @@ import type { Request, Response, NextFunction } from 'express' import type { Schema } from "yup"; -import { validateSchema } from '../../utils/validateSchema'; +import { validateSchema } from '../utils/validateSchema'; // TODO: add validate by params and query params export const ValidateSchema = ( diff --git a/src/middlewares/index.ts b/src/middlewares/index.ts index c046158..0347acb 100644 --- a/src/middlewares/index.ts +++ b/src/middlewares/index.ts @@ -1,2 +1,3 @@ export * from './guard' export * from './handlerException' +export * from './SchemaValidation'