-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
54 lines (43 loc) · 1.09 KB
/
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
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
// import / intial
require('dotenv').config()
const express = require('express')
const app = express()
const bodyParser = require('body-parser')
const helmet = require('helmet')
const xssClean = require('xss-clean')
const cors = require('cors')
const compression = require('compression')
const fileUpload = require('express-fileupload')
// import routes
const usersRoutes = require('./routes/users.routes')
const recipesRouter = require('./routes/recipes.routes')
const authRoutes = require('./routes/auth.routes')
// parse application
app.use(bodyParser.urlencoded({ extended: false }))
// parse appliaction Json
app.use(bodyParser.json())
// Use helmet
app.use(helmet())
// Use xss-clean
app.use(xssClean())
// Use cors
app.use(cors())
// use compression
app.use(compression())
// grame acces to upload file
app.use(
fileUpload({
useTempFiles: true,
tempFileDir: '/tmp/'
})
)
// Use router
app.use(usersRoutes)
app.use(recipesRouter)
app.use(authRoutes)
app.get("/", function (req, res) {
res.send("Hello World");
});
app.listen(8000, () => {
console.log('App running in port 8000')
})