-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
44 lines (37 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
require("dotenv").config()
require("express-async-errors")
const { loadRoutes } = require("./helpers/methods")
const express = require("express")
const helmet = require("helmet")
const cors = require("cors")
/**
* Create a new express app.
*/
const app = express()
/**
* Enable helmet for all routes. You can change this to only allow specific origins.
* See helmet documentation for more info.
* @see https://www.npmjs.com/package/helmet
*/
app.use(helmet());
/**
* Enable cors for all routes and origins. You can change this to only allow specific origins.
* See cors documentation for more info.
* @see https://www.npmjs.com/package/cors
*/
app.use(cors())
/**
* Enable json body parsing for all routes. You can change this to only allow specific origins.
* See express documentation for more info.
* @see https://expressjs.com/en/api.html#express.json
*/
app.use(express.json())
/**
* Load all routes from the routes folder.
*/
loadRoutes(app)
/**
* Export the express app.
* @type {Express}
*/
module.exports = app