forked from PersistentPoplars/inventive-ironwood
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server-config.js
58 lines (42 loc) · 1.71 KB
/
server-config.js
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
var path = require('path');
var handler = require('./request-handler');
var express = require('express');
var bodyParser = require('body-parser');
var db = require('./app/config');
var session = require('express-session');
var morgan = require('morgan');
var app = express();
// Get IP of client in req.ip
app.enable('trust proxy');
app.use(morgan('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(session({secret: 'keyboard cat', resave: false, saveUninitialized: true}));
app.use(express.static(path.join(__dirname, './newClient')));
app.post('/api/signin', handler.signin);
app.post('/api/signup', handler.signup);
//-----------------------------------------------------
// SECURE ROUTES
//-----------------------------------------------------
// app.use(handler.check);
app.get('/logout', handler.logout);
app.get('/api/currency', handler.currency);
app.post('/api/transactions', handler.transactions);
app.get('/api/transactions', handler.getTransactions);
app.post('/api/debts', handler.debts);
app.get('/api/debts', handler.getDebts);
app.get('/api/budget', handler.getBudget);
app.post('/api/budget', handler.createBudget);
app.post('/api/transfer', handler.transfer);
app.get('/api/user', handler.getUser);
app.get('/api/users/:userStr', handler.filterUsers);
app.post('/api/loans', handler.createLoan);
app.get('/api/loans/:which', handler.getLoansByType);
app.put('/api/loans', handler.updateLoan);
app.delete('/api/loans', handler.deleteLoan);
app.post('/api/transfer', handler.transfer);
app.get('/api/iavtoken', handler.getIavToken);
app.get('*', function (req, res) {
res.sendFile(path.resolve(__dirname + '/newClient/index.html'));
});
module.exports = app;