-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
38 lines (26 loc) · 960 Bytes
/
server.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
require('dotenv').config()
require('dotenv').config({path: './.env'})
const express = require('express')
const bodyParser = require('body-parser')
const cors = require('cors')
const config = require('./server/config')
const path = require("path")
const app = express()
app.use(express.static('public'))
app.use(cors())
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({extended: true}))
app.get('/', (req, res) => {
return res.send(require('./helpers/welcome_api').welcomge_msg)
})
app.get('/public', express.static(path.join(__dirname, "./public")))
app.get("/public/images/:name", (req, res) => {
return res.sendFile(path.join(__dirname, `./public/images/${req.params.name}`));
})
app.use(require('./server/secured').authorization)
app.use('/api', require('./api'))
// app.listen(3001, '0.0.0.0', () => {
app.listen(config.port, () => {
console.log('Server listening on port %s, Ctrl+C to stop', config.port)
})
module.exports = app