-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
36 lines (30 loc) · 1010 Bytes
/
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
const express = require('express');
const usersRoutes = require('./src/routes/users_routes');
const blesRoutes = require('./src/routes/bles_routes');
const azureRoutes = require('./src/routes/azure_routes');
const bodyParser = require('body-parser');
const app = express();
app.use((req, res, next) => {
res.setHeader('Access-Control-Allow-Origin', '*');
next();
})
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
app.use(bodyParser.json());
//Initiate Mongo Server
const InitiateMongoServer = require("./src/config/db_init");
InitiateMongoServer.createMongoose();
app.get("/", (req, res) => {
res.json({ message: "API Working Cool" });
});
app.use('/', usersRoutes);
app.use('/ble', blesRoutes);
app.use('/azure', azureRoutes);
app.use(function(err, req, res, next){
res.send({theError: err.message});
})
const port = process.env.PORT || 4000;
app.listen(port, (err) => {
if (err) throw err
console.log(`Server running in http://127.0.0.1: ${port}`)
})