diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/hero.mjs | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/src/hero.mjs b/src/hero.mjs index 7ac7c19..451198d 100644 --- a/src/hero.mjs +++ b/src/hero.mjs @@ -178,12 +178,9 @@ export const makeLogger = (writerFn = console.error) => ({ export const log = makeLogger(); export const interceptorsFn = ({ - uuidFn, - logger, -} = { - uuidFn: crypto.randomUUID, - logger: log, -}) => ({ + uuidFn = crypto.randomUUID, + logger = log, +} = {}) => ({ requestId: (req, next) => next({ ...req, id: uuidFn() }), logged: async (req, next) => { const { id, url, method } = req; @@ -256,10 +253,8 @@ export const wrapHandler = (fn, arr) => chainInterceptors(arr.concat([ (req, _next) => fn(req) ])); export const actionsFn = ({ - logger, -} = { - logger: log, -}) => ({ + logger = log, +} = {}) => ({ "toggle-debug-env": action => { const before = process.env.DEBUG; if (process.env.DEBUG) { @@ -291,12 +286,9 @@ export const actionsFn = ({ export const actions = actionsFn(); export const lineHandlerFn = ({ - logger, - actionsMap, -} = { - logger: log, - actionsMap: actions, -}) => line => { + logger = log, + actionsMap = actions, +} = {}) => line => { let cmd = null; try { cmd = JSON.parse(line); @@ -359,10 +351,8 @@ export const makeLineEmitter = fn => { }; export const makePipeReaderFn = ({ - lineFn, -} = { - lineFn: lineHandler -}) => path => { + lineFn = lineHandler, +} = {}) => path => { mkfifo(path); fs.createReadStream(path, "UTF-8").on("data", makeLineEmitter(lineFn)); }; |