File tree Expand file tree Collapse file tree 5 files changed +12
-15
lines changed Expand file tree Collapse file tree 5 files changed +12
-15
lines changed Original file line number Diff line number Diff line change 1
1
import express , { Request , Response } from 'express'
2
- import path from 'path'
3
2
import { asyncHandler } from '~/lib/async-handler'
4
3
import HttpResponse from '~/lib/http/response'
4
+ import { currentDir } from '~/lib/string'
5
5
import { v1Route } from './v1'
6
6
7
7
const route = express . Router ( )
8
- const dirname = path . join ( __dirname , '../../../' )
9
8
10
9
function versioning ( ) {
11
- const node_modules = `${ dirname } /node_modules`
10
+ const node_modules = `${ currentDir } /node_modules`
12
11
const express = require ( `${ node_modules } /express/package.json` ) . version
13
- const app = require ( `${ dirname } /package.json` ) . version
12
+ const app = require ( `${ currentDir } /package.json` ) . version
14
13
15
14
return { express : `v${ express } ` , app : `v${ app } ` }
16
15
}
Original file line number Diff line number Diff line change @@ -16,10 +16,9 @@ import expressWithState from '~/app/middleware/with-state'
16
16
import { Route } from '~/app/routes/route'
17
17
import { allowedCors } from '~/lib/constant/allowed-cors'
18
18
import ErrorResponse from '~/lib/http/errors'
19
+ import { currentDir } from '~/lib/string'
19
20
import { httpLogger } from './logger'
20
21
21
- const dirname = path . join ( __dirname , '../../' )
22
-
23
22
export class App {
24
23
private _app : Application
25
24
@@ -33,7 +32,7 @@ export class App {
33
32
this . _app . use ( httpLogger )
34
33
this . _app . use ( express . json ( { limit : '20mb' , type : 'application/json' } ) )
35
34
this . _app . use ( express . urlencoded ( { extended : true } ) )
36
- this . _app . use ( express . static ( path . resolve ( `${ dirname } /public` ) ) )
35
+ this . _app . use ( express . static ( path . resolve ( `${ currentDir } /public` ) ) )
37
36
this . _app . use ( compression ( ) )
38
37
this . _app . use ( cookieParser ( ) )
39
38
this . _app . use ( helmet ( ) )
Original file line number Diff line number Diff line change @@ -3,9 +3,9 @@ import { randomUUID } from 'crypto'
3
3
import path from 'path'
4
4
import pino from 'pino'
5
5
import { pinoHttp } from 'pino-http'
6
+ import { currentDir } from '~/lib/string'
6
7
7
- const dirname = path . join ( __dirname , '../../' )
8
- const logDir = path . resolve ( `${ dirname } /logs` )
8
+ const logDir = path . resolve ( `${ currentDir } /logs` )
9
9
10
10
const fileTransport = pino . transport ( {
11
11
target : 'pino/file' ,
Original file line number Diff line number Diff line change @@ -5,10 +5,9 @@ import fs from 'fs'
5
5
import path from 'path'
6
6
import { logger } from '~/config/logger'
7
7
import { ms } from '../date'
8
+ import { currentDir } from '../string'
8
9
import { GoogleCloudStorageParams , UploadFileParams } from './types'
9
10
10
- const dirname = path . join ( __dirname , '../../../' )
11
-
12
11
export default class GoogleCloudStorage {
13
12
public client : GCS . Storage
14
13
@@ -21,7 +20,7 @@ export default class GoogleCloudStorage {
21
20
this . _access_key = params . access_key
22
21
this . _bucket = params . bucket
23
22
this . _expires = params . expires
24
- this . _filepath = path . resolve ( `${ dirname } /${ params . filepath } ` )
23
+ this . _filepath = path . resolve ( `${ currentDir } /${ params . filepath } ` )
25
24
26
25
const msgType = `${ green ( 'storage - google cloud storage' ) } `
27
26
Original file line number Diff line number Diff line change @@ -3,10 +3,10 @@ import _ from 'lodash'
3
3
import path from 'path'
4
4
import swaggerJSDoc from 'swagger-jsdoc'
5
5
import { env } from '~/config/env'
6
+ import { currentDir } from '../string'
6
7
7
- const dirname = path . join ( __dirname , '../../../' , 'public' , 'swagger' )
8
- const _pathRouteDocs = path . resolve ( `${ dirname } /routes` )
9
- const _pathSchemaDocs = path . resolve ( `${ dirname } /schema` )
8
+ const _pathRouteDocs = path . resolve ( `${ currentDir } /public/swagger/routes` )
9
+ const _pathSchemaDocs = path . resolve ( `${ currentDir } /public/swagger/schema` )
10
10
11
11
function _getDocsSwaggers ( _path : string | Buffer ) : Record < string , unknown > {
12
12
return fs . readdirSync ( _path ) . reduce ( ( acc , file ) => {
You can’t perform that action at this time.
0 commit comments