aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/specs
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit/specs')
0 files changed, 0 insertions, 0 deletions
v>
d6af2106 ^
c196dae1 ^
7ab3036c ^
d2286994 ^
cb30426a ^
c0888fab ^
b45deffe ^
2b59255e ^
12091db2 ^
1ac57d20 ^

2b59255e ^
a2a2bd06 ^
9f29f46b ^
a2a2bd06 ^


d6af2106 ^
a2a2bd06 ^
d6af2106 ^

a2a2bd06 ^
d6af2106 ^
6fe6c1b9 ^
c196dae1 ^
c0888fab ^
88837c9e ^
c0888fab ^




75149f56 ^
64ed7a01 ^









3ae8bf7c ^
64ed7a01 ^






c0888fab ^
01e85e75 ^
c0888fab ^


d6af2106 ^
c0888fab ^
6fe6c1b9 ^
fae6e8b5 ^
c0888fab ^
4bde8faf ^
75149f56 ^
9f29f46b ^
c405440c ^
a2a2bd06 ^
c0888fab ^
a0e36844 ^
139000e7 ^
4bde8faf ^
c0888fab ^
96dff083 ^
75149f56 ^
4bde8faf ^
75149f56 ^



75149f56 ^

0fb703b8 ^
75149f56 ^
75149f56 ^


75149f56 ^

75149f56 ^


cf1fc09b ^

4bde8faf ^

cf1fc09b ^
4bde8faf ^
6388e2b9 ^
cf1fc09b ^
76a16fcb ^

c1dff6b2 ^



b4314761 ^

d277cd3e ^
















b4314761 ^
d277cd3e ^

c1dff6b2 ^

d277cd3e ^
c1dff6b2 ^


c0888fab ^
49065ec0 ^



12091db2 ^
baba2be1 ^
49065ec0 ^


a85ed161 ^
c0888fab ^
1ac57d20 ^
12091db2 ^
1ac57d20 ^
99d71f03 ^
c0888fab ^


18814242 ^
c0888fab ^
2873f690 ^


4bde8faf ^
2873f690 ^

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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
                               
                                          

                                              

                                   
                                    
                                         
 
                                      
 
                             
              
                                             
               

                       
 
               
               


                
            
          

              
                 
 
                                           
 
                 
                                   




                                                   
 









                                                     
                                                   






                               
                        
                                                  


                                     
 
                
                         
                       
                         
                          
                          
                          
                      
                      
 
                           
                         
 
                          
 
                                         
                                  



                                               

                                 
 
                                         


                                                  

                               


                            

                              

                                                       
 
                                               
                                          
 

                     



                                             

         
















                                                              
                                              

                                    

                   
                                  


   
                                  



                     
                    
    


                                                     
                                                       
                  
           
                               
     
                        


                                
                                                          
  


                                   
                                                     

                         
const axios = require("axios");
const bodyParser = require("body-parser");
const compression = require("compression");
const cookieParser = require("cookie-parser");
const cors = require("cors");
const express = require("express");
const { Op } = require("sequelize");
const persist = require("./lib/persist");

ah = require("express-async-handler");

config = require("./config");
networks = [];
prod = process.env.NODE_ENV === "production";
fail = msg => {
  throw new Error(msg);
};

addresses = {};
challenge = {};
change = [];
exceptions = [];
issuances = {};
logins = {};
seen = [];
sessions = {};
sockets = {};
unaccounted = [];

convert = persist("data/conversions.json");

SATS = 100000000;
toSats = n => Math.round(n * SATS);

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());

server = require("http").Server(app);

require("./db");
require("./lib/logging");
require("./lib/utils");
require("./lib/sockets");
require("./lib/webhooks");
require("./lib/passport");
require("./lib/register");
require("./lib/send");
require("./lib/sync");

require("./routes/assets");
require("./routes/info");

require("./routes/users");

// Exclude plugins for minimalist version
if (process.env.SCOPE !== "MIN") {
  if (config.bitcoin) networks.push("bitcoin");
  if (config.liquid) networks.push("liquid");
  if (config.lna) networks.push("lightning");

  require("./lib/rates");
  require("./lib/notifications");

  if (config.imap) require("./lib/mail");
  if (config.lnurl) require("./routes/lnurl");
  if (config.mailgun) require("./routes/funding");

  require("./routes/invoices");
  require("./routes/payments");
  require("./routes/swaps");
}

//  Scope based Route Handling

var referralsRouter = require("./routes/referrals.js");
app.use("/referrals", referralsRouter);

var adminRouter = require("./routes/admin.js");
app.use("/admin", adminAuth, adminRouter);

require("./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.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("uncaught error: ", JSON.stringify(details));
  res.status(500);
  res.set({
    "Cache-Control": "no-cache"
  });
  res.send(err.message);
});

server.listen(config.port, () =>
  l.info(`CoinOS Server listening on port ${config.port}`)
);

process.on("SIGINT", process.exit);

process.on("uncaughtException", function(exception) {
  console.log(exception);
});