From f54df1cb50730add7c254137c7a6452d0ae68226 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Sat, 16 Mar 2024 07:38:31 -0300 Subject: src/web.mjs: Add "WEBSOCKET" route --- src/web.mjs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/web.mjs b/src/web.mjs index c3651a9..5128a1e 100644 --- a/src/web.mjs +++ b/src/web.mjs @@ -1,17 +1,18 @@ import * as u from "./utils.mjs"; import * as hero from "./hero.mjs"; -const listProducts = req => ({ status: 200 }); -const getProduct = req => ({ status: 200, body: "PRODUTO\n" }); -const getSocket = req => ({ status: 200, body: "SOCKET\n" }); - const name = "papo"; +const newConnection = (req, ws) => { + // console.log({ ws, req }); + // ws.on("error", console.error); + // ws.on("message", x => console.log(x.toString())); + // ws.send("hello from the server"); +}; + const routes = [ - [ "GET", "/api/products", listProducts ], - [ "GET", "/api/products/:id", getProduct ], - [ "GET", "/api/socket", getSocket ], + [ "WEBSOCKET", "/api/socket", newConnection ], ]; export const app = async (socket, pipe) => { -- cgit v1.2.3