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) • 649 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.HapiListener = void 0;
const events_1 = require("events");
class HapiListener extends events_1.EventEmitter {
listen(_port, maybeCallback, maybeCallback2) {
let callback = typeof maybeCallback === 'function' ? maybeCallback : undefined;
if (!callback) {
callback = typeof maybeCallback2 === 'function' ? maybeCallback2 : undefined;
}
if (callback) {
callback();
}
}
get handler() {
return (req, res) => this.emit('request', req, res);
}
}
exports.HapiListener = HapiListener;