1
- import { Application , Request , Response } from " express" ;
2
- import { apiMessage , errorMessage } from " ../logger" ;
3
- import { existsSync } from "fs" ;
4
- import { resolve } from " path" ;
1
+ import { Application , Request , Response } from ' express' ;
2
+ import { apiMessage , errorMessage } from ' ../logger' ;
3
+ import { existsSync } from 'fs' ;
4
+ import { resolve } from ' path' ;
5
5
6
6
export default ( app : Application ) => {
7
7
app . get ( '/:name' , async ( req : Request , res : Response ) => {
@@ -10,9 +10,9 @@ export default (app: Application) => {
10
10
apiMessage ( req . path , `User is trying to get a file - ${ fileName } ` ) ;
11
11
const fileNamePattern = / ^ [ a - z A - Z 0 - 9 _ - ] + $ / ;
12
12
if ( ! fileNamePattern . test ( fileName ) ) {
13
- return res . status ( 400 ) . json ( { error : " Invalid file name" } ) ;
13
+ return res . status ( 400 ) . json ( { error : ' Invalid file name' } ) ;
14
14
}
15
- const filePath = resolve ( __dirname , " ../" , " files" , fileName ) ;
15
+ const filePath = resolve ( __dirname , ' ../' , ' files' , fileName ) ;
16
16
if ( ! existsSync ( filePath ) ) {
17
17
errorMessage ( `File ${ fileName } not found` ) ;
18
18
return res . status ( 404 ) . send ( { sucsess : false , message : `File ${ fileName } not found` } ) ;
0 commit comments