1- import express , { NextFunction , Request , Response } from 'express'
1+ import express , { NextFunction , Request , Response } from 'express' ;
22import i18next from 'i18next' ;
3- import middleware from 'i18next-http-middleware'
4- import './utils/i18nextSetup'
5- import 'reflect-metadata'
3+ import middleware from 'i18next-http-middleware' ;
4+ import './utils/i18nextSetup' ;
5+ import 'reflect-metadata' ;
66import { validateOrReject } from 'class-validator-custom-errors' ;
77import { plainToClass } from 'class-transformer' ;
88import { Url } from './schemas/Url' ;
9- const app = express ( )
10- app . use ( [
11- middleware . handle ( i18next ) ,
12- express . json ( ) ,
13- express . urlencoded ( { extended : true } ) ,
14- ] ) ;
9+ const app = express ( ) ;
10+ app . use ( [ middleware . handle ( i18next ) , express . json ( ) , express . urlencoded ( { extended : true } ) ] ) ;
1511app . post ( '/urls/create' , async ( req : Request , res : Response , next : NextFunction ) => {
1612 try {
1713 await validateOrReject ( plainToClass ( Url , req . body ) , {
1814 whitelist : true ,
1915 validationError : {
2016 target : false ,
21- transformFunction : ( key : string ) => req . t ( `validation.${ key } ` )
22- }
23- } )
24- res . json ( { success : true , message : req . t ( " success" ) , errors : null } )
17+ transformFunction : ( key : string ) => req . t ( `validation.${ key } ` ) ,
18+ } ,
19+ } ) ;
20+ res . json ( { success : true , message : req . t ( ' success' ) , errors : null } ) ;
2521 } catch ( error ) {
26- res . json ( { success : false , message : req . t ( " failure" ) , errors : error } )
22+ res . json ( { success : false , message : req . t ( ' failure' ) , errors : error } ) ;
2723 }
28- } )
29- export default app
24+ } ) ;
25+ export default app ;
0 commit comments