aboutsummaryrefslogtreecommitdiffstats
path: root/docker-compose.yml
Commit message (Expand)AuthorAgeFilesLines
* lnd v0.13.1-betaAdam Soltys2021-08-041-1/+1
* config update, lnd supportAdam Soltys2021-08-041-55/+12
* change overrides so default is to use a dev build rather than dev webpackAdam Soltys2021-07-291-9/+0
* accept filename and pubkey for issuanceAdam Soltys2021-07-281-0/+1
* rename nginx containerAdam Soltys2021-07-191-3/+3
* override with dev uiAdam Soltys2021-07-191-2/+1
* nginx confAdam Soltys2021-07-191-6/+9
* translate env vars for k8sAdam Soltys2021-07-181-6/+0
* docker compose override for development ui containerAdam Soltys2021-07-131-3/+1
* add a second ln node for testingAdam Soltys2021-07-111-2/+10
* add webhooks to invoicesAdam Soltys2021-07-091-3/+3
* add webhooks to invoicesAdam Soltys2021-07-071-1/+1
* remove redundant funding routesAdam Soltys2021-06-161-20/+0
* config updateAdam Soltys2021-06-091-9/+22
* remove mountpointAdam Soltys2021-06-091-2/+0
* ui dev imageAdam Soltys2021-06-091-0/+20
* update sample configAdam Soltys2021-06-091-3/+0
* changes to dev environmentAdam Soltys2021-06-091-7/+20
* docker compose fileAdam Soltys2021-06-091-79/+10
* deps cleanupAdam Soltys2021-06-091-0/+151
'>12091db2 ^
89519c0c ^





































































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
124
125
126
127
128
129
130
131
132
                                                      







                                               

                                                                   












                                          









                                                             
 
                



                                               
      
 
                                  
                                         



              
 









                                                          
                                               

              





































































                                                                               
const mailgun = require("mailgun-js")(config.mailgun);
const multer = require("multer");

const storage = multer.diskStorage({
  destination: (req, file, cb) => {
    cb(null, "uploads");
  },
  filename: (req, file, cb) => {
    const parts = file.originalname.split(".");
    const ext = parts.length > 1 ? parts[parts.length - 1] : "bin";
    cb(null, `${req.user.username}-${file.fieldname}.${ext}`);
  }
});

const upload = multer({
  storage,
  onFileUploadStart: (file, req, res) => {
    const maxSize = 32 * 1000 * 1000;
    if (req.files.file.length > maxSize) {
      return false;
    }
  }
});

app.post(
  "/id",
  auth,
  upload.single("id"),
  ah(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}`,
      from: "[email protected]",
      to: "[email protected]"
    };

    mailgun.messages().send(data);
    l.info("id uploaded", user.username);

    res.end();
  })
);

app.post(
  "/proof",
  auth,
  upload.single("proof"),
  ah(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.info("id proof uploaded", user.username);

    res.end();
  })
);

app.post(
  "/funding",
  auth,
  ah(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) {
      l.error("funding error", e.message);
      res.status(500).send("Funding request failed");
    }
  })
);

app.post(
  "/withdrawal",
  auth,
  ah(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.end();
    } catch (e) {
      l.error("withdrawal error", e.message);
      res.status(500).send("Withdrawal request failed");
    }
  })
);