aboutsummaryrefslogtreecommitdiffstats
path: root/routes/funding.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-01-08 21:05:34 -0800
committerAdam Soltys <[email protected]>2023-01-08 21:05:34 -0800
commitdce07aa93b3c2f47aca0c24cea6adde9ec37f1a7 (patch)
tree6c6b8930ebe9c2cc5b8d1f759e61260f509fdd7a /routes/funding.js
parentf7b844883506a8072213245b9b8a2b988694e4f5 (diff)
downloadcoinos-server-dce07aa93b3c2f47aca0c24cea6adde9ec37f1a7.tar.gz
coinos-server-dce07aa93b3c2f47aca0c24cea6adde9ec37f1a7.zip
tech debt jubilee
Diffstat (limited to 'routes/funding.js')
-rw-r--r--routes/funding.js96
1 files changed, 0 insertions, 96 deletions
diff --git a/routes/funding.js b/routes/funding.js
deleted file mode 100644
index e65a704e..00000000
--- a/routes/funding.js
+++ /dev/null
@@ -1,96 +0,0 @@
-import { emit } from "$lib/sockets";
-import app from "$app";
-import config from "$config";
-import mailgunFactory from "mailgun-js";
-const mailgun = mailgunFactory(config.mailgun);
-
-app.post("/id", auth, upload.single("id"), async (req, res) => {
- const { user } = req;
- if (user.verified === "proof") user.verified = "pending";
- else user.verified = "id";
- await user.save();
- emit(user.username, "user", user);
-
- let data = {
- subject: "KYC Documents",
- text: `ID uploaded for ${user.username}`,
- };
-
- mailgun.messages().send(data);
- l("id uploaded", user.username);
-
- res.send({});
-});
-
-app.post("/proof", auth, upload.single("proof"), async (req, res) => {
- const { user } = req;
- if (user.verified === "id") user.verified = "pending";
- else user.verified = "proof";
- await user.save();
- emit(user.username, "user", user);
- l("id proof uploaded", user.username);
-
- res.send({});
-});
-
-app.post("/funding", auth, async (req, res) => {
- try {
- let { id, amount, code } = req.body;
-
- if (!code) {
- code = "";
- let d = "ABCDEFGHIJKLMNPQRSTUVWXYZ23456789";
- let l = d.length;
- for (let i = 0; i < 8; i++) {
- code += d.charAt(Math.floor(Math.random() * l));
- }
- }
-
- let params = {
- user_id: req.user.id,
- amount,
- code
- };
-
- let deposit;
- if (id) {
- if (!parseFloat(amount) || parseFloat(amount) < 0)
- throw new Error("Invalid amount");
- deposit = await db.Deposit.findOne({ where: { id } });
- deposit.update(params);
- await deposit.save();
- } else {
- deposit = await db.Deposit.create(params);
- }
-
- res.send(deposit);
- } catch (e) {
- err("funding error", e.message);
- res.code(500).send("Funding request failed");
- }
-});
-
-app.post("/withdrawal", auth, async (req, res) => {
- try {
- const { account, amount, email, institution, transit, notes } = req.body;
- if (!parseFloat(amount) || parseFloat(amount) < 0)
- throw new Error("Invalid amount");
-
- await db.Withdrawal.create({
- user_id: req.user.id,
- account,
- amount,
- email,
- institution,
- transit,
- notes
- });
-
- res.send({});
- } catch (e) {
- err("withdrawaerr", e.message);
- res.code(500).send("Withdrawal request failed");
- }
-});