diff options
Diffstat (limited to 'src/hero.mjs')
-rw-r--r-- | src/hero.mjs | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/hero.mjs b/src/hero.mjs index 8cbbe36..0a086ad 100644 --- a/src/hero.mjs +++ b/src/hero.mjs @@ -357,6 +357,17 @@ export const makeLineEmitter = fn => { }; }; +export const makePipeReaderFn = ({ + lineFn, +} = { + lineFn: lineHandler +}) => path => { + mkfifo(path); + // TODO +}; + +export const makePipeReader = makePipeReaderFn(); + export const buildRoutes = (routes, globalInterceptors = []) => routes.reduce( (acc, [methods, path, handlerFn, interceptors = []]) => @@ -374,12 +385,16 @@ export const buildRoutes = (routes, globalInterceptors = []) => export const promisifyServer = (name, serverHandle) => ({ ref: serverHandle, - listen: util.promisify((udsPath, ...args) => { + listen: util.promisify((socket, pipe, ...args) => { + assert.equal(typeof socket, "string"); + assert.equal(typeof pipe, "string"); configLogger({ name }); - if (fs.existsSync(udsPath)) { - fs.unlinkSync(udsPath); - } - return serverHandle.listen(udsPath, ...args) + + rmIf(pipe); + makePipeReader(pipe); + + rmIf(socket); + return serverHandle.listen(socket, ...args) }), close: util.promisify((...args) => serverHandle.close(...args)), events: serverHandle, |