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

0.0.1 • Public • Published

Centurio

Server Frame built on top of Fastify

Installation

$ (p)npm add @ayezee/centurio

# or yarn
$ yarn add @ayezee/centurio

Example

import {app, enableWebSocket} from "centurio";

async function main() {
  const c = await app({logger: false, trustProxy: true});

  await enableWebSocket({
    options: {
      maxPayload: 32 * 1024,
      clientTracking: true
    }
  });

  c.get("/", async (req, res) => {
    res.send({
      message: "hello"
    });
  });

  c.ws("/ws", (ws) => {
    ws.on("message", (message) => {
      const data = c.getMessageData(message);
      console.log("[Centurio] got WebSocket message:", data);
    });
  });

  c.bindTo("0.0.0.0");
  c.listenAtPort(Number(process.env.PORT ?? 3000));

  await c.run();
}

main();

Readme

Keywords

none

Package Sidebar

Install

npm i @ayezee/centurio

Weekly Downloads

0

Version

0.0.1

License

none

Unpacked Size

36.9 kB

Total Files

26

Last publish

Collaborators

  • kocisov