Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarkko Mönkkönen authored and Jarkko Mönkkönen committed Oct 30, 2024
1 parent 4d470b7 commit 705cddb
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 32 deletions.
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"nodemon": "^1.10.2",
"nyc": "^15.1.0",
"prettier-standard": "^16.4.1",
"rxjs": "^7.8.1",
"stream-buffers": "^3.0.2",
"supertest": "^6.1.3",
"typescript": "^4.2.4"
Expand All @@ -104,6 +105,9 @@
"prettyjson": "^1.1.3",
"sorted-object": "^2.0.1"
},
"overrides": {
"find-parent-dir": "0.3.1"
},
"standard": {
"parser": "babel-eslint",
"ignore": [
Expand Down
12 changes: 6 additions & 6 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ export default function run (opts = {}) {
const protocol = _.startsWith('https', proxyHost)
? 'https'
: _.startsWith('http', proxyHost)
? 'http'
: undefined
? 'http'
: undefined
return {
path: proxyPart === undefined ? undefined : pathPart,
host: parsedHost.host,
Expand All @@ -137,10 +137,10 @@ export default function run (opts = {}) {
value === undefined
? undefined
: /^(?:y|yes|true|1|on)$/i.test(value)
? true
: /^(?:n|no|false|0|off)$/i.test(value)
? false
: showMessageAndExit(`Invalid value '${value}' for ${flagName}`)
? true
: /^(?:n|no|false|0|off)$/i.test(value)
? false
: showMessageAndExit(`Invalid value '${value}' for ${flagName}`)

if (unknownArgs) {
cli.showHelp(1)
Expand Down
8 changes: 4 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@ export default function consoleLogServer (opts) {
hostPath: _.startsWith('/', hostPath)
? hostPath
: hostPath === undefined
? '/'
: '/' + hostPath,
? '/'
: '/' + hostPath,
path: (path === undefined
? '/'
: _.startsWith('/', path)
? path
: `/${path || ''}`
? path
: `/${path || ''}`
).trim()
}
}, /** @type {CLSProxy[]} */ (opts.proxy))
Expand Down
38 changes: 19 additions & 19 deletions src/logging.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ export function logRequest (req, res, opts) {
const pathLine = `${req.method} ${req.originalUrl}`
const div = !err
? divider(
ctx.yellow.bold(pathLine) +
(proxyUrl ? proxyArrow + ctx.yellow.bold(proxyUrl) : '')
)
ctx.yellow.bold(pathLine) +
(proxyUrl ? proxyArrow + ctx.yellow.bold(proxyUrl) : '')
)
: divider(
ctx.red.bold(pathLine) +
(proxyUrl ? proxyArrow + ctx.red.bold(proxyUrl) : '') +
ctx.red.bold(' *error*')
)
ctx.red.bold(pathLine) +
(proxyUrl ? proxyArrow + ctx.red.bold(proxyUrl) : '') +
ctx.red.bold(' *error*')
)
cnsl.log()
div.begin()
const headers = req.headers
Expand Down Expand Up @@ -176,15 +176,15 @@ export function logResponse (/** @type {RequestExt} */ req, res, opts) {
const div =
res.statusCode < 400
? divider(
ctx.green.bold(statusPreFix) +
ctx.yellow.bold(pathLine) +
(proxyUrl ? proxyArrow + ctx.yellow.bold(proxyUrl) : '')
)
ctx.green.bold(statusPreFix) +
ctx.yellow.bold(pathLine) +
(proxyUrl ? proxyArrow + ctx.yellow.bold(proxyUrl) : '')
)
: divider(
ctx.red.bold(statusPreFix) +
ctx.red.bold(pathLine) +
(proxyUrl ? proxyArrow + ctx.red.bold(proxyUrl) : '')
)
ctx.red.bold(statusPreFix) +
ctx.red.bold(pathLine) +
(proxyUrl ? proxyArrow + ctx.red.bold(proxyUrl) : '')
)
cnsl.log()
div.begin()

Expand All @@ -196,8 +196,8 @@ export function logResponse (/** @type {RequestExt} */ req, res, opts) {
res.locals.body === undefined
? 'empty'
: _.isString(contentType)
? mime.extension(contentType)
: 'raw'
? mime.extension(contentType)
: 'raw'

try {
switch (bodyType) {
Expand Down Expand Up @@ -241,8 +241,8 @@ export function logResponse (/** @type {RequestExt} */ req, res, opts) {
ctx.magenta('body: ') +
(bodyType
? ctx.yellow(
`(${bodyType} - as raw string, no formatting support yet)`
)
`(${bodyType} - as raw string, no formatting support yet)`
)
: ctx.yellow('(as raw string)'))
)
cnsl.log(ctx.white(res.locals.body.toString()))
Expand Down
6 changes: 3 additions & 3 deletions src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ export default opts => {
userResDecorator:
opts.logResponse !== false
? function (proxyRes, proxyResData, userReq, userRes) {
userRes.locals.body = proxyResData.toString('utf8')
return proxyResData
}
userRes.locals.body = proxyResData.toString('utf8')
return proxyResData
}
: undefined,
proxyErrorHandler: function (err, res, next) {
const msg = { message: err.toString() }
Expand Down

0 comments on commit 705cddb

Please sign in to comment.