mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-02-21 12:49:07 +00:00
fix: removed readline dependency
it was honestly never supposed to be written that way but i very rarely used it so i never noticed the actual readline module that we use is a node core module https://nodejs.org/docs/latest-v12.x/api/readline.html#readline_readline_createinterface_options additionally improved its formatting and whatnot
This commit is contained in:
parent
52c121721b
commit
b4e32a6001
21
lolisafe.js
21
lolisafe.js
@ -18,7 +18,6 @@ const NodeClam = require('clamscan')
|
|||||||
const nunjucks = require('nunjucks')
|
const nunjucks = require('nunjucks')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const rateLimit = require('express-rate-limit')
|
const rateLimit = require('express-rate-limit')
|
||||||
const readline = require('readline')
|
|
||||||
const serveStatic = require('@bobbywibowo/serve-static')
|
const serveStatic = require('@bobbywibowo/serve-static')
|
||||||
const { accessSync, constants } = require('fs')
|
const { accessSync, constants } = require('fs')
|
||||||
|
|
||||||
@ -407,27 +406,27 @@ safe.use('/api', api)
|
|||||||
|
|
||||||
// NODE_ENV=development yarn start
|
// NODE_ENV=development yarn start
|
||||||
if (isDevMode) {
|
if (isDevMode) {
|
||||||
|
const { inspect } = require('util')
|
||||||
// Add readline interface to allow evaluating arbitrary JavaScript from console
|
// Add readline interface to allow evaluating arbitrary JavaScript from console
|
||||||
readline.createInterface({
|
require('readline').createInterface({
|
||||||
input: process.stdin,
|
input: process.stdin
|
||||||
output: process.stdout,
|
|
||||||
prompt: ''
|
|
||||||
}).on('line', line => {
|
}).on('line', line => {
|
||||||
try {
|
try {
|
||||||
if (line === 'rs') return
|
if (line === 'rs') return
|
||||||
if (line === '.exit') return process.exit(0)
|
if (line === '.exit') return process.exit(0)
|
||||||
// eslint-disable-next-line no-eval
|
// eslint-disable-next-line no-eval
|
||||||
logger.log(eval(line))
|
const evaled = eval(line)
|
||||||
|
process.stdout.write(`${typeof evaled === 'string' ? evaled : inspect(evaled)}\n`)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(error.toString())
|
process.stderr.write(`${error.stack}\n`)
|
||||||
}
|
}
|
||||||
}).on('SIGINT', () => {
|
}).on('SIGINT', () => {
|
||||||
process.exit(0)
|
process.exit(0)
|
||||||
})
|
})
|
||||||
logger.log('!!! DEVELOPMENT MODE !!!')
|
logger.log(utils.stripIndents(`!!! DEVELOPMENT MODE !!!
|
||||||
logger.log('- Nunjucks will auto rebuild (not live reload)')
|
[=] Nunjucks will auto rebuild (not live reload)
|
||||||
logger.log('- Rate limits disabled')
|
[=] HTTP rate limits disabled
|
||||||
logger.log('- Readline interface enabled')
|
[=] Readline interface enabled (eval arbitrary JS input)`))
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(error)
|
logger.error(error)
|
||||||
|
@ -51,7 +51,6 @@
|
|||||||
"node-fetch": "~2.6.7",
|
"node-fetch": "~2.6.7",
|
||||||
"nunjucks": "~3.2.3",
|
"nunjucks": "~3.2.3",
|
||||||
"randomstring": "~1.2.2",
|
"randomstring": "~1.2.2",
|
||||||
"readline": "~1.3.0",
|
|
||||||
"search-query-parser": "~1.6.0",
|
"search-query-parser": "~1.6.0",
|
||||||
"sharp": "~0.30.4",
|
"sharp": "~0.30.4",
|
||||||
"sqlite3": "~5.0.8",
|
"sqlite3": "~5.0.8",
|
||||||
|
@ -5762,11 +5762,6 @@ readdirp@~3.6.0:
|
|||||||
dependencies:
|
dependencies:
|
||||||
picomatch "^2.2.1"
|
picomatch "^2.2.1"
|
||||||
|
|
||||||
readline@~1.3.0:
|
|
||||||
version "1.3.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/readline/-/readline-1.3.0.tgz#c580d77ef2cfc8752b132498060dc9793a7ac01c"
|
|
||||||
integrity sha1-xYDXfvLPyHUrEySYBg3JeTp6wBw=
|
|
||||||
|
|
||||||
rechoir@^0.6.2:
|
rechoir@^0.6.2:
|
||||||
version "0.6.2"
|
version "0.6.2"
|
||||||
resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384"
|
resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384"
|
||||||
|
Loading…
Reference in New Issue
Block a user