UNPKG

in-process-request

Version:

A node.js library that executes a http handler function in the current process without having to start a local http server.

20 lines (19 loc) 593 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const serverFactory = (handler) => { return { __handler: handler, on: () => { }, once: () => { }, removeListener: () => { }, address: () => "0.0.0.0", listen: (_, cb) => { cb(); }, }; }; const fastifyHandler = (fastifyBuilder) => (options = {}) => { const app = fastifyBuilder(Object.assign(Object.assign({}, options), { serverFactory })); return app.listen(0).then(() => app.server.__handler); }; exports.default = fastifyHandler;