-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
52 lines (43 loc) · 1.26 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
45
46
47
48
49
50
51
52
const express = require('express');
require('dotenv').config();
const app = express();
const morgan = require('morgan');
const cookieParser = require('cookie-parser');
const fileUpload = require('express-fileupload');
// for swagger documentation
const swaggerUi = require('swagger-ui-express');
const YAML = require('yamljs');
const swaggerDocument = YAML.load('./swagger.yaml');
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument));
// Regular middleware
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
//cookies and file middleware
app.use(cookieParser());
app.use(
fileUpload({
useTempFiles: true,
tempFileDir: '/tmp/',
})
);
// temp check
app.set('view engine', 'ejs');
// morgan middleware
app.use(morgan('tiny'));
// import all routes here
const home = require('./routes/home');
const user = require('./routes/user');
const product = require('./routes/product');
const payment = require('./routes/payment');
const order = require('./routes/order');
// router middleware
app.use('/api/v1', home);
app.use('/api/v1', user);
app.use('/api/v1', product);
app.use('/api/v1', payment);
app.use('/api/v1', order);
app.get('/signuptest', (req, res) => {
res.render('signuptest');
});
// export app.js
module.exports = app;