0.0.1 • Published 3 years ago
@ayezee/centurio v0.0.1
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();
0.0.1
3 years ago