Skip to content

Commit fc3d564

Browse files
committed
fix: update current dir
1 parent 93e6f4b commit fc3d564

File tree

5 files changed

+12
-15
lines changed

5 files changed

+12
-15
lines changed

src/app/routes/route.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
import express, { Request, Response } from 'express'
2-
import path from 'path'
32
import { asyncHandler } from '~/lib/async-handler'
43
import HttpResponse from '~/lib/http/response'
4+
import { currentDir } from '~/lib/string'
55
import { v1Route } from './v1'
66

77
const route = express.Router()
8-
const dirname = path.join(__dirname, '../../../')
98

109
function versioning() {
11-
const node_modules = `${dirname}/node_modules`
10+
const node_modules = `${currentDir}/node_modules`
1211
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
1413

1514
return { express: `v${express}`, app: `v${app}` }
1615
}

src/config/app.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@ import expressWithState from '~/app/middleware/with-state'
1616
import { Route } from '~/app/routes/route'
1717
import { allowedCors } from '~/lib/constant/allowed-cors'
1818
import ErrorResponse from '~/lib/http/errors'
19+
import { currentDir } from '~/lib/string'
1920
import { httpLogger } from './logger'
2021

21-
const dirname = path.join(__dirname, '../../')
22-
2322
export class App {
2423
private _app: Application
2524

@@ -33,7 +32,7 @@ export class App {
3332
this._app.use(httpLogger)
3433
this._app.use(express.json({ limit: '20mb', type: 'application/json' }))
3534
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`)))
3736
this._app.use(compression())
3837
this._app.use(cookieParser())
3938
this._app.use(helmet())

src/config/logger.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { randomUUID } from 'crypto'
33
import path from 'path'
44
import pino from 'pino'
55
import { pinoHttp } from 'pino-http'
6+
import { currentDir } from '~/lib/string'
67

7-
const dirname = path.join(__dirname, '../../')
8-
const logDir = path.resolve(`${dirname}/logs`)
8+
const logDir = path.resolve(`${currentDir}/logs`)
99

1010
const fileTransport = pino.transport({
1111
target: 'pino/file',

src/lib/storage/gcs.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ import fs from 'fs'
55
import path from 'path'
66
import { logger } from '~/config/logger'
77
import { ms } from '../date'
8+
import { currentDir } from '../string'
89
import { GoogleCloudStorageParams, UploadFileParams } from './types'
910

10-
const dirname = path.join(__dirname, '../../../')
11-
1211
export default class GoogleCloudStorage {
1312
public client: GCS.Storage
1413

@@ -21,7 +20,7 @@ export default class GoogleCloudStorage {
2120
this._access_key = params.access_key
2221
this._bucket = params.bucket
2322
this._expires = params.expires
24-
this._filepath = path.resolve(`${dirname}/${params.filepath}`)
23+
this._filepath = path.resolve(`${currentDir}/${params.filepath}`)
2524

2625
const msgType = `${green('storage - google cloud storage')}`
2726

src/lib/swagger/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import _ from 'lodash'
33
import path from 'path'
44
import swaggerJSDoc from 'swagger-jsdoc'
55
import { env } from '~/config/env'
6+
import { currentDir } from '../string'
67

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`)
1010

1111
function _getDocsSwaggers(_path: string | Buffer): Record<string, unknown> {
1212
return fs.readdirSync(_path).reduce((acc, file) => {

0 commit comments

Comments
 (0)