File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import express , { Request , Response } from 'express'
22import { asyncHandler } from '~/lib/async-handler'
33import HttpResponse from '~/lib/http/response'
4- import { __dirname , require } from '~/lib/string'
4+ import { currentDir , require } from '~/lib/string'
55import { v1Route } from './v1'
66
77const route = express . Router ( )
88
99function versioning ( ) {
10- const node_modules = `${ __dirname } /node_modules`
10+ const node_modules = `${ currentDir } /node_modules`
1111 const express = require ( `${ node_modules } /express/package.json` ) . version
12- const app = require ( `${ __dirname } /package.json` ) . version
12+ const app = require ( `${ currentDir } /package.json` ) . version
1313
1414 return { express : `v${ express } ` , app : `v${ app } ` }
1515}
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ import expressWithState from '~/app/middleware/with-state'
1616import { Route } from '~/app/routes/route'
1717import { allowedCors } from '~/lib/constant/allowed-cors'
1818import ErrorResponse from '~/lib/http/errors'
19- import { __dirname } from '~/lib/string'
19+ import { currentDir } from '~/lib/string'
2020import { httpLogger } from './logger'
2121
2222export class App {
@@ -32,7 +32,7 @@ export class App {
3232 this . _app . use ( httpLogger )
3333 this . _app . use ( express . json ( { limit : '20mb' , type : 'application/json' } ) )
3434 this . _app . use ( express . urlencoded ( { extended : true } ) )
35- this . _app . use ( express . static ( path . resolve ( `${ __dirname } /public` ) ) )
35+ this . _app . use ( express . static ( path . resolve ( `${ currentDir } /public` ) ) )
3636 this . _app . use ( compression ( ) )
3737 this . _app . use ( cookieParser ( ) )
3838 this . _app . use ( helmet ( ) )
Original file line number Diff line number Diff line change @@ -3,9 +3,9 @@ import { randomUUID } from 'crypto'
33import path from 'path'
44import pino from 'pino'
55import { pinoHttp } from 'pino-http'
6- import { __dirname } from '~/lib/string'
6+ import { currentDir } from '~/lib/string'
77
8- const logDir = path . resolve ( `${ __dirname } /logs` )
8+ const logDir = path . resolve ( `${ currentDir } /logs` )
99
1010const fileTransport = pino . transport ( {
1111 target : 'pino/file' ,
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import { addDays } from 'date-fns'
44import fs from 'fs'
55import path from 'path'
66import { logger } from '~/config/logger'
7- import { __dirname } from '~/lib/string'
7+ import { currentDir } from '~/lib/string'
88import { ms } from '../date'
99import { GoogleCloudStorageParams , UploadFileParams } from './types'
1010
@@ -20,7 +20,7 @@ export default class GoogleCloudStorage {
2020 this . _access_key = params . access_key
2121 this . _bucket = params . bucket
2222 this . _expires = params . expires
23- this . _filepath = path . resolve ( `${ __dirname } /${ params . filepath } ` )
23+ this . _filepath = path . resolve ( `${ currentDir } /${ params . filepath } ` )
2424
2525 const msgType = `${ green ( 'storage - google cloud storage' ) } `
2626
Original file line number Diff line number Diff line change 11import { createRequire } from 'module'
22import path from 'path'
33import { fileURLToPath } from 'url'
4+ import { cwd } from 'node:process'
45
56const __filename = fileURLToPath ( import . meta. url )
67export const require = createRequire ( import . meta. url )
78export const __dirname = path . join ( path . dirname ( __filename ) , '../../' )
9+ export const currentDir = cwd ( )
Original file line number Diff line number Diff line change @@ -3,10 +3,10 @@ import _ from 'lodash'
33import path from 'path'
44import swaggerJSDoc from 'swagger-jsdoc'
55import { env } from '~/config/env'
6- import { __dirname , require } from '../string'
6+ import { currentDir , require } from '../string'
77
8- const _pathRouteDocs = path . resolve ( `${ __dirname } /public/swagger/routes` )
9- const _pathSchemaDocs = path . resolve ( `${ __dirname } /public/swagger/schema` )
8+ const _pathRouteDocs = path . resolve ( `${ currentDir } /public/swagger/routes` )
9+ const _pathSchemaDocs = path . resolve ( `${ currentDir } /public/swagger/schema` )
1010
1111function _getDocsSwaggers ( _path : string | Buffer ) : Record < string , unknown > {
1212 return fs . readdirSync ( _path ) . reduce ( ( acc , file ) => {
You can’t perform that action at this time.
0 commit comments