@spectrum-ts/fastify
v9.1.0
Published
Fastify webhook adapter for spectrum-ts.
Readme
@spectrum-ts/fastify
Fastify webhook adapter for spectrum-ts.
Install
bun add spectrum-ts @spectrum-ts/fastify fastifyUse
import { Spectrum } from "spectrum-ts";
import { spectrum } from "@spectrum-ts/fastify";
import Fastify from "fastify";
const app = await Spectrum({
webhookSecret: process.env.SPECTRUM_WEBHOOK_SECRET,
});
const server = Fastify();
// The plugin owns its own raw-body parser in an encapsulated scope.
server.register(spectrum, {
app,
onMessage: async (space, message) => {
if (message.content.type === "text") {
await space.send(`echo: ${message.content.text}`);
}
},
});
// Await listen so a startup failure surfaces instead of going unhandled.
await server.listen({ port: 3000 });See the spectrum-ts documentation for the full guide.
