1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
import app from "./app.js";
import axios from "axios";
import bodyParser from "body-parser";
import compression from "compression";
import cookieParser from "cookie-parser";
import cors from "cors";
import express from "express";
import { Op } from "@sequelize/core";
import persist from "./lib/persist.js";
import config from "./config/index.js";
import { networks } from "./lib/store.js";
// app = express();
// app.enable("trust proxy");
// app.use(bodyParser.urlencoded({ extended: true });
// app.use(bodyParser.json());
//
// app.use((err, req, res, next) => {
// const details = {
// path: req.path,
// body: req.body,
// msg: err.message,
// stack: err.stack
// };
//
// if (req.user) details.username = req.user.username;
//
// l.error("JSON Error: ", JSON.stringify(details));
// res.status(500);
// res.set({
// "Cache-Control": "no-cache"
// });
// res.send(err.message);
// return res.end();
// });
// app.use(cookieParser());
// app.use(cors({ credentials: true, origin: "*" });
// app.use(compression());
import "./lib/logging.js";
import "./lib/utils.js";
import "./lib/sockets.js";
import "./lib/webhooks.js";
import "./lib/passport.js";
import "./lib/register.js";
import "./lib/upload.js";
import "./lib/send.js";
import "./lib/sync.js";
import "./routes/assets.js";
import "./routes/info.js";
import "./routes/users.js";
if (config.bitcoin) networks.push("bitcoin");
if (config.liquid) networks.push("liquid");
if (config.lna) networks.push("lightning");
import "./lib/rates.js";
import "./lib/notifications.js";
if (config.imap) import("./lib/mail.js");
if (config.lnurl) import("./routes/lnurl.js");
if (config.mailgun) import ("./routes/funding.js");
import "./routes/invoices.js";
import "./routes/payments.js";
// import "./routes/swaps.js";
// Scope based Route Handling
// import referralsRouter from './routes/referrals.js';
// app.use("/referrals", referralsRouter);
// import adminRouter from './routes/admin.js';
// app.use("/admin", adminAuth, adminRouter);
import "./startup.js";
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(process.env.PORT || 3119, "0.0.0.0", function(err, address) {
if (err) {
console.log(err);
app.log.error(err);
process.exit(1);
}
app.log.info(`CoinOS Server listening on ${address}`);
});
process.on("SIGINT", process.exit);
process.on("uncaughtException", function(exception) {
console.log(exception);
});
|