Server Frame built on top of Fastify
$ (p)npm add centurio
# or yarn
$ yarn add centurio
import centurio from "centurio";
const c = centurio({logger: true, trustProxy: true})
.enableRateLimit({max: 128, timeWindow: 5 * 60 * 1000})
.enableWebSocket({
options: {
clientTracking: true,
maxPayload: 64 * 1024,
},
})
.bind("0.0.0.0")
.port("3000")
.create();
c.get("/*", async (req, res) => {
res.send({success: false});
});
c.ws<{room: string}>("/rooms/:room", async (ws, req) => {
ws.on("message", (message) => {
const data = c.getWSData<{type: string}>(message);
if (data.type === "test") {
ws.send(JSON.stringify({test: true}));
}
});
});
c.run();