UNPKG

vag_tools

Version:

api and cli for managing sub-git-repositories

42 lines (41 loc) 1.15 kB
#!/usr/bin/env node // src/vagg_server.ts import { Hono } from "hono"; import { serve as honoServer } from "@hono/node-server"; import { serveStatic } from "@hono/node-server/serve-static"; import { Server as WSserver } from "socket.io"; import { setTimeout as sleep } from "timers/promises"; console.log("hello from vagg_server.ts!"); var app = new Hono(); var port = 3e3; var httpServer = honoServer({ fetch: app.fetch, port: 3e3 }); app.get("/api/abc", (ctx) => { return ctx.text("Hello from /api/abc"); }); app.get("/api/currDir", (ctx) => { const rCurrDir = process.cwd(); return ctx.text(rCurrDir); }); var publicAbsPath = "./dist/public"; app.use( "*", serveStatic({ root: publicAbsPath, onNotFound: (path, ctx) => { console.log(`dbg028: ${path} is not found, request to ${ctx.req.path}`); } }) ); var io = new WSserver(httpServer, {}); io.on("connection", (socket) => { socket.emit("hello", "worldy"); socket.on("howdy", (arg) => { console.log(`server receives: ${arg}`); }); }); await sleep(100); console.log(`vagg_server is running on port ${port}`); //# sourceMappingURL=vagg_server.js.map