-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
44 lines (34 loc) · 1.02 KB
/
app.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
const express = require('express');
const cors = require('cors');
const toobusy_js = require('toobusy-js');
const apiErrorHandler = require('./error/ApiErrorHandler');
const apiError = require('./error/ApiError');
const indexRouter = require('./routes/index.route.js');
const authRouter = require('./routes/auth.route.js');
const walletRouter = require('./routes/wallet.route.js');
const { server, app } = require('./server');
require('dotenv').config();
require('./config/database.config');
require('./knexfile');
require('./config/redis.config');
app.use(
cors({
origin: '*',
})
);
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use('/', indexRouter);
app.use('/api/v1/auth', authRouter);
app.use('/api/v1/wallet', walletRouter);
app.use(apiErrorHandler);
app.disable('x-powered-by');
if (toobusy_js) {
apiError.badRequest('Server is busy.');
}
app.use(function (req, res, next) {
return res.status(404).json('Page not found');
});
///call and start the server
server();
module.exports = app;