diff options
| author | Adam Soltys <[email protected]> | 2022-09-07 13:11:12 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2022-09-07 13:11:12 -0700 |
| commit | 06b59b585ac9af7be106b9c1271d251ba20f6630 (patch) | |
| tree | d01db8fa25ade19c534f9ac34b11c3bff1ac507d /index.js | |
| parent | ca5ccaf2deeba7eda2c16fd1b7d33aa4c25e960f (diff) | |
| download | coinos-server-06b59b585ac9af7be106b9c1271d251ba20f6630.tar.gz coinos-server-06b59b585ac9af7be106b9c1271d251ba20f6630.zip | |
clean up
Diffstat (limited to 'index.js')
| -rw-r--r-- | index.js | 79 |
1 files changed, 11 insertions, 68 deletions
@@ -2,7 +2,7 @@ import app from "./app"; import persist from "./lib/persist"; import config from "./config/index"; import store from "./lib/store"; -import { l } from "./lib/logging"; +import { l, err } from "./lib/logging"; import "./db"; import "./lib/sockets"; @@ -10,82 +10,25 @@ import "./lib/webhooks"; import "./lib/passport"; import "./lib/upload"; import "./lib/sync"; +import "./lib/rates"; +import "./lib/notifications"; +import "./lib/mail"; + import "./routes/assets"; import "./routes/info"; import "./routes/users"; +import "./routes/invoices"; +import "./routes/payments"; if (config.bitcoin) store.networks.push("bitcoin"); if (config.liquid) store.networks.push("liquid"); if (config.lna) store.networks.push("lightning"); - -import "./lib/rates"; -import "./lib/notifications"; - -// if (config.imap) import("./lib/mail"); // if (config.lnurl) import("./routes/lnurl"); -// if (config.mailgun) import("./routes/funding"); -// -import "./routes/invoices"; -import "./routes/payments"; -// import "./routes/swaps"; - -// Scope based Route Handling -// import referralsRouter from './routes/referrals'; +let host = process.env.HOST || "0.0.0.0"; +let port = process.env.PORT || 3119; -// app.use("/referrals", referralsRouter); - -// import adminRouter from './routes/admin'; -// app.use("/admin", adminAuth, adminRouter); - -import "./startup"; - -app.post("/email", async (req, res) => { - try { - let file = persist("data/emails.json"); - file.emails = [...file.emails, req.body]; - - try { - // Require: - var postmark = require("postmark"); - - // Send an email: - var client = new postmark.ServerClient(config.postmark); - - await client.sendEmail({ - From: "[email protected]", - To: "[email protected]", - Subject: req.body.subject || "Email Signup", - HtmlBody: JSON.stringify(req.body), - TextBody: JSON.stringify(req.body), - MessageStream: "outbound" - }); - - res.send({ ok: true }); - } catch (e) { - console.log("problem sending email", e); - res.code(500).send(e.message); - } - } catch (e) { - console.log(e); - res.code(500).send(e.message); - } -}); - -app.listen({ port: process.env.PORT || 3119, host: "0.0.0.0" }, function( - err, - address -) { - if (err) { - console.log(err); - app.log.error(err); - process.exit(1); - } +app.listen({ host, port }, (e, address) => { + e && err(e) && process.exit(1); l(`CoinOS Server listening on ${address}`); }); - -process.on("SIGINT", process.exit); - -process.on("uncaughtException", function(exception) { - console.log(exception); -}); |
