@quiltjs/quilt
Version:
Lightweight, type-safe handler and router abstraction for Node HTTP servers.
45 lines • 1.28 kB
JavaScript
/**
* Adapter that implements the ServerEngine interface using Fastify.
*/
export class FastifyEngineAdapter {
fastify;
constructor({ fastify }) {
this.fastify = fastify;
}
post(path, handler) {
this.fastify.post(path, async (request, reply) => {
await handler(request, reply);
});
}
get(path, handler) {
this.fastify.get(path, async (request, reply) => {
await handler(request, reply);
});
}
patch(path, handler) {
this.fastify.patch(path, async (request, reply) => {
await handler(request, reply);
});
}
put(path, handler) {
this.fastify.put(path, async (request, reply) => {
await handler(request, reply);
});
}
delete(path, handler) {
this.fastify.delete(path, async (request, reply) => {
await handler(request, reply);
});
}
options(path, handler) {
this.fastify.options(path, async (request, reply) => {
await handler(request, reply);
});
}
head(path, handler) {
this.fastify.head(path, async (request, reply) => {
await handler(request, reply);
});
}
}
//# sourceMappingURL=FastifyEngineAdapter.js.map