11import { Router } from "express" ;
22import fs from "fs" ;
33import multer from "multer" ;
4- import { isAuthorizedByRole } from "../middlewares/auth" ;
4+ // import { isAuthorizedByRole } from "../middlewares/auth";
55import { entityRequestDtoValidator } from "../middlewares/validators/entityValidators" ;
66import EntityService from "../services/implementations/entityService" ;
7- import FileStorageService from "../services/implementations/fileStorageService" ;
8- import IFileStorageService from "../services/interfaces/fileStorageService" ;
7+ // import FileStorageService from "../services/implementations/fileStorageService";
8+ // import IFileStorageService from "../services/interfaces/fileStorageService";
99import {
1010 EntityResponseDTO ,
1111 IEntityService ,
@@ -16,13 +16,13 @@ import { sendResponseByMimeType } from "../utilities/responseUtil";
1616const upload = multer ( { dest : "uploads/" } ) ;
1717
1818const entityRouter : Router = Router ( ) ;
19- entityRouter . use ( isAuthorizedByRole ( new Set ( [ "User" , "Admin" ] ) ) ) ;
19+ // entityRouter.use(isAuthorizedByRole(new Set(["User", "Admin"])));
2020
2121const defaultBucket = process . env . FIREBASE_STORAGE_DEFAULT_BUCKET || "" ;
22- const fileStorageService : IFileStorageService = new FileStorageService (
23- defaultBucket ,
24- ) ;
25- const entityService : IEntityService = new EntityService ( fileStorageService ) ;
22+ // const fileStorageService: IFileStorageService = new FileStorageService(
23+ // defaultBucket,
24+ // );
25+ // const entityService: IEntityService = new EntityService(fileStorageService);
2626
2727/* Create entity */
2828entityRouter . post (
@@ -32,19 +32,19 @@ entityRouter.post(
3232 async ( req , res ) => {
3333 try {
3434 const body = JSON . parse ( req . body . body ) ;
35- const newEntity = await entityService . createEntity ( {
36- stringField : body . stringField ,
37- intField : body . intField ,
38- enumField : body . enumField ,
39- stringArrayField : body . stringArrayField ,
40- boolField : body . boolField ,
41- filePath : req . file ?. path ,
42- fileContentType : req . file ?. mimetype ,
43- } ) ;
35+ // const newEntity = await entityService.createEntity({
36+ // stringField: body.stringField,
37+ // intField: body.intField,
38+ // enumField: body.enumField,
39+ // stringArrayField: body.stringArrayField,
40+ // boolField: body.boolField,
41+ // filePath: req.file?.path,
42+ // fileContentType: req.file?.mimetype,
43+ // });
4444 if ( req . file ?. path ) {
4545 fs . unlinkSync ( req . file . path ) ;
4646 }
47- res . status ( 201 ) . json ( newEntity ) ;
47+ // res.status(201).json(newEntity);
4848 } catch ( e : unknown ) {
4949 res . status ( 500 ) . send ( getErrorMessage ( e ) ) ;
5050 }
@@ -55,13 +55,13 @@ entityRouter.post(
5555entityRouter . get ( "/" , async ( req , res ) => {
5656 const contentType = req . headers [ "content-type" ] ;
5757 try {
58- const entities = await entityService . getEntities ( ) ;
59- await sendResponseByMimeType < EntityResponseDTO > (
60- res ,
61- 200 ,
62- contentType ,
63- entities ,
64- ) ;
58+ // const entities = await entityService.getEntities();
59+ // await sendResponseByMimeType<EntityResponseDTO>(
60+ // res,
61+ // 200,
62+ // contentType,
63+ // entities,
64+ // );
6565 } catch ( e : unknown ) {
6666 await sendResponseByMimeType ( res , 500 , contentType , [
6767 {
@@ -76,8 +76,8 @@ entityRouter.get("/:id", async (req, res) => {
7676 const { id } = req . params ;
7777
7878 try {
79- const entity = await entityService . getEntity ( id ) ;
80- res . status ( 200 ) . json ( entity ) ;
79+ // const entity = await entityService.getEntity(id);
80+ // res.status(200).json(entity);
8181 } catch ( e : unknown ) {
8282 res . status ( 500 ) . send ( getErrorMessage ( e ) ) ;
8383 }
@@ -92,19 +92,19 @@ entityRouter.put(
9292 const { id } = req . params ;
9393 try {
9494 const body = JSON . parse ( req . body . body ) ;
95- const entity = await entityService . updateEntity ( id , {
96- stringField : body . stringField ,
97- intField : body . intField ,
98- enumField : body . enumField ,
99- stringArrayField : body . stringArrayField ,
100- boolField : body . boolField ,
101- filePath : req . file ?. path ,
102- fileContentType : req . file ?. mimetype ,
103- } ) ;
95+ // const entity = await entityService.updateEntity(id, {
96+ // stringField: body.stringField,
97+ // intField: body.intField,
98+ // enumField: body.enumField,
99+ // stringArrayField: body.stringArrayField,
100+ // boolField: body.boolField,
101+ // filePath: req.file?.path,
102+ // fileContentType: req.file?.mimetype,
103+ // });
104104 if ( req . file ?. path ) {
105105 fs . unlinkSync ( req . file . path ) ;
106106 }
107- res . status ( 200 ) . json ( entity ) ;
107+ // res.status(200).json(entity);
108108 } catch ( e : unknown ) {
109109 res . status ( 500 ) . send ( getErrorMessage ( e ) ) ;
110110 }
@@ -116,8 +116,8 @@ entityRouter.delete("/:id", async (req, res) => {
116116 const { id } = req . params ;
117117
118118 try {
119- const deletedId = await entityService . deleteEntity ( id ) ;
120- res . status ( 200 ) . json ( { id : deletedId } ) ;
119+ // const deletedId = await entityService.deleteEntity(id);
120+ // res.status(200).json({ id: deletedId });
121121 } catch ( e : unknown ) {
122122 res . status ( 500 ) . send ( getErrorMessage ( e ) ) ;
123123 }
@@ -127,8 +127,8 @@ entityRouter.delete("/:id", async (req, res) => {
127127entityRouter . get ( "/files/:fileUUID" , async ( req , res ) => {
128128 const { fileUUID } = req . params ;
129129 try {
130- const fileURL = await fileStorageService . getFile ( fileUUID ) ;
131- res . status ( 200 ) . json ( { fileURL } ) ;
130+ // const fileURL = await fileStorageService.getFile(fileUUID);
131+ // res.status(200).json({ fileURL });
132132 } catch ( e : unknown ) {
133133 res . status ( 500 ) . send ( getErrorMessage ( e ) ) ;
134134 }
0 commit comments