forked from decoded-cipher/api.inovuslabs.org
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.js
43 lines (30 loc) · 833 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
39
40
41
42
43
require('dotenv').config();
const db = require('./config/db');
db.connect();
const express = require('express');
const app = express();
app.disable('x-powered-by');
var cors = require('cors')
app.use(cors())
const swagger = require('./config/swagger');
swagger(app);
const routes = require('./routes');
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use('/', routes);
app.use((req, res, next) => {
res.status(404).json({
status: 404,
message: 'Resource not found'
})
});
app.use((err, req, res, next) => {
console.error(err.stack);
res.status(500).json({
status: 500,
message: 'Internal server error'
})
});
app.listen((process.env.PORT || 3000), () => {
console.log(`\n--- Server listening on port ${process.env.PORT || 3000}`)
});