node-httpx-server
Version:
A node HTTP/2 server and beyond dealing with streams
30 lines • 1.07 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.StreamRouter = void 0;
const helpers_1 = require("./helpers");
class StreamRouter {
constructor() {
this.generateRoute = (method) => (path, ...callbacks) => {
this.routers.set([path, method], callbacks);
};
this.process = ({ currentPath, onComplete, onError, pathParameters, searchParams, source, }) => {
(0, helpers_1.processRoutes)({
currentPath,
onComplete,
onError,
pathParameters,
routers: this.routers,
searchParams,
source,
});
};
this.delete = this.generateRoute('DELETE');
this.get = this.generateRoute('GET');
this.patch = this.generateRoute('PATCH');
this.post = this.generateRoute('POST');
this.put = this.generateRoute('PUT');
this.routers = new Map();
}
}
exports.StreamRouter = StreamRouter;
//# sourceMappingURL=streamRouter.js.map