From 91e847126c832efa25ab0bf8d6f3b7e537378fa7 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 16 Jan 2023 23:40:25 -0800 Subject: shuffle things around --- index.js | 87 +++++++++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 67 insertions(+), 20 deletions(-) (limited to 'index.js') diff --git a/index.js b/index.js index 640f7389..7d4aa135 100644 --- a/index.js +++ b/index.js @@ -1,24 +1,71 @@ -import app from "./app.js"; -import { l, err } from "$lib/logging"; - -import "$lib/redis"; -import "$lib/sockets"; -import "$lib/passport"; -import "$lib/upload"; -import "$lib/rates"; -import "$lib/notifications"; -import "$lib/mail"; -import "$lib/nostr"; - -import "$routes/locations"; -import "$routes/invoices"; -import "$routes/payments"; -import "$routes/users"; -import "$routes/requests"; +import app from "$app"; +import { auth, optional } from "$lib/auth"; +import { getLocations } from "$lib/locations"; +import { getRates, sendRates } from "$lib/rates"; +import { sendHeartbeat } from "$lib/sockets"; + +import email from "$routes/email"; +import locations from "$routes/locations"; +import nostr from "$routes/nostr"; +import rates from "$routes/rates"; +import invoices from "$routes/invoices"; +import users from "$routes/users"; +import payments from "$routes/payments"; +import requests from "$routes/requests"; + +getLocations(); +getRates(); + +setInterval(sendRates, 1000); +setInterval(sendHeartbeat, 2000); + +app.post("/email", email.send); + +app.get("/rate", rates.last); +app.get("/rates", rates.index); + +app.get("/nostr.json", nostr.identities); +app.get("/:pubkey/followers", nostr.followers); +app.get("/:pubkey/follows", nostr.follows); +app.get("/:pubkey/notes", nostr.notes); +app.get("/event/:id", nostr.event); +app.post("/event", nostr.broadcast); + +app.get("/locations", locations.list); + +app.get("/invoice", invoices.get); +app.post("/invoice", optional, invoices.create); + +app.post("/send", auth, payments.send); +app.get("/payments", auth, payments.list); +app.get("/payments/:hash", auth, payments.get); +app.post("/lightning/send", auth, payments.sendLightning); + +app.get("/voucher/:id", payments.voucher); +app.post("/redeem", optional, payments.redeem); + +app.get("/me", auth, users.me); +app.get("/users/:key", users.get); +app.post("/register", users.create); +app.post("/disable2fa", users.disable2fa); +app.post("/2fa", auth, users.enable2fa); +app.post("/user", auth, users.update); +app.post("/upload/:type", auth, users.upload); + +app.post("/login", users.login); +app.post("/logout", optional, users.logout); + +app.post("/subscribe", auth, users.subscribe); +app.post("/password", auth, users.password); +app.post("/otpsecret", auth, users.otpsecret); +app.get("/contacts", auth, users.contacts); + +app.get("/request/:id", requests.get); +app.get("/requests", requests.list); +app.post("/requests", requests.create); +app.post("/requests/delete", requests.destroy); let host = process.env.HOST || "0.0.0.0"; let port = process.env.PORT || 3119; -app.listen({ host, port }, (e, h) => { - if (e) return err("Failed to start:", e.message); -}); +app.listen({ host, port }); -- cgit v1.2.3