-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
29 lines (26 loc) · 987 Bytes
/
index.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
require('dotenv').config();
const express = require('express'),
app = express(),
bodyParser = require('body-parser'),
cors = require('cors'),
expressSanitizer = require('express-sanitizer'),
mongoSanitize = require('express-mongo-sanitize'),
helmet = require('helmet'),
authRoutes = require('./routes/auth'),
transactionRoutes = require('./routes/transactions'),
accountRoutes = require('./routes/accounts'),
{redirectToHTTPS} = require('./middleware');
app.use(redirectToHTTPS);
app.use(cors());
app.use(bodyParser.json());
app.use(expressSanitizer());
app.use(mongoSanitize());
app.use(helmet());
app.use('/api/auth', authRoutes);
app.use('/api/accounts/:accountId/transactions/', transactionRoutes);
app.use('/api/accounts', accountRoutes);
app.use(function(req, res, next) {
return res.status(404).json({error: 'Route not found'});
});
const PORT = process.env.PORT || 3001
app.listen(PORT, () => console.log(`Listening on port ${PORT}`));