From 394aa39c75650c76a26ac1d43ab0908c4074b82c Mon Sep 17 00:00:00 2001 From: juliecoust Date: Tue, 7 Jan 2025 14:32:10 +0100 Subject: [PATCH] DEV : Clean code : add validation middleware where missing --- src/main.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main.ts b/src/main.ts index a7d56c8..c8118e2 100644 --- a/src/main.ts +++ b/src/main.ts @@ -5,6 +5,8 @@ import { MiddlewareAuthValidation } from './presentation/middleware/auth-validat import { MiddlewareUserValidation } from './presentation/middleware/user-validation' import { MiddlewareProjectValidation } from './presentation/middleware/project-validation' import { MiddlewareSampleValidation } from './presentation/middleware/sample-validation' +import { MiddlewareInstrumentModelValidation } from './presentation/middleware/instrument_model-validation' +import { MiddlewareTaskValidation } from './presentation/middleware/task-validation' import UserRouter from './presentation/routers/user-router' import AuthRouter from './presentation/routers/auth-router' @@ -65,9 +67,10 @@ import { FsAdapter } from './infra/files/fs' import sqlite3 from 'sqlite3' import path from 'path' - import 'dotenv/config' + + sqlite3.verbose() const config = { @@ -169,7 +172,8 @@ async function getSQLiteDS() { ) const instrumentModelMiddleWare = InstrumentModelRouter( new GetOneInstrumentModel(instrument_model_repo), - new SearchInstrumentModels(instrument_model_repo, search_repo) + new SearchInstrumentModels(instrument_model_repo, search_repo), + new MiddlewareInstrumentModelValidation() ) const projectMiddleWare = ProjectRouter( new MiddlewareAuthCookie(jwtAdapter, config.ACCESS_TOKEN_SECRET, config.REFRESH_TOKEN_SECRET), @@ -189,6 +193,7 @@ async function getSQLiteDS() { const taskMiddleWare = TaskRouter( new MiddlewareAuthCookie(jwtAdapter, config.ACCESS_TOKEN_SECRET, config.REFRESH_TOKEN_SECRET), + new MiddlewareTaskValidation(), new DeleteTask(user_repo, task_repo, privilege_repo), new GetOneTask(task_repo, user_repo, privilege_repo), new GetLogFileTask(task_repo, user_repo, privilege_repo),