diff options
author | EuAndreh <eu@euandre.org> | 2024-03-16 07:38:31 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2024-03-16 07:38:31 -0300 |
commit | f54df1cb50730add7c254137c7a6452d0ae68226 (patch) | |
tree | 37c2d447595b60ded7c2f99fdc7844fe265d3b15 | |
parent | src/hero.mjs: Move interceptors.contentType() closer to the end of the list (diff) | |
download | papod-f54df1cb50730add7c254137c7a6452d0ae68226.tar.gz papod-f54df1cb50730add7c254137c7a6452d0ae68226.tar.xz |
src/web.mjs: Add "WEBSOCKET" route
-rw-r--r-- | src/web.mjs | 15 |
1 files 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) => { |