summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2024-03-01 16:08:55 -0300
committerEuAndreh <eu@euandre.org>2024-03-01 16:08:55 -0300
commit7105a65ff10d082f9b2157d7f8dd217a8cd53eec (patch)
tree49890da9f527dec6374dceb128737fbc0185dd26
parentsrc/ircd.mjs: Remove unix socket before recreating it (diff)
downloadpapod-7105a65ff10d082f9b2157d7f8dd217a8cd53eec.tar.gz
papod-7105a65ff10d082f9b2157d7f8dd217a8cd53eec.tar.xz
src/web.mjs: Try out new hero API
-rw-r--r--src/web.mjs26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/web.mjs b/src/web.mjs
index cd875a0..3ca2544 100644
--- a/src/web.mjs
+++ b/src/web.mjs
@@ -1,18 +1,18 @@
-import * as u from "./utils.mjs";
-import { buildServer, defaultInterceptors } from "./hero.mjs";
-
+import * as u from "./utils.mjs";
+import * as hero from "./hero.mjs";
const listProducts = req => ({ status: 200 });
-const getProduct = req => ({ status: 200 });
-const getChat = req => ({ status: 200, body: "something\n" });
+const getProduct = req => ({ status: 200, body: "PRODUTO" });
+const getSocket = req => ({ status: 200, body: "SOCKET" });
+
-const server = buildServer([
- [ "GET", "/products", listProducts ],
- [ "GET", "/products/:id", getProduct ],
- [ "GET", "/chat", getChat ],
-], defaultInterceptors);
+const server = hero.buildServer("papo", [
+ [ "GET", "/api/products", listProducts ],
+ [ "GET", "/api/products/:id", getProduct ],
+ [ "GET", "/api/socket", getSocket ],
+]);
-export const app = async udsPath => {
- await server.listen(udsPath);
- u.log({ type: "starting-server", udsPath });
+export const app = async path => {
+ await server.listen(path);
+ hero.log.info({ type: "starting-server", path });
};