centurio
TypeScript icon, indicating that this package has built-in type declarations

0.0.6 • Public • Published

Centurio

Server Frame built on top of Fastify

Installation

$ (p)npm add centurio

# or yarn
$ yarn add centurio

Example

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();

Package Sidebar

Install

npm i centurio

Weekly Downloads

0

Version

0.0.6

License

MIT

Unpacked Size

7.51 kB

Total Files

6

Last publish

Collaborators

  • kocisov