-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
39 lines (25 loc) · 954 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
var cors = require('cors');
var express = require('express'),
app = express(),
port = process.env.PORT || 3000,
ip = process.env.IP || '0.0.0.0',
mongoose = require('mongoose'),
Champions = require('./api/models/OKrammusModel'), //created model loading here
bodyParser = require('body-parser');
// DATABASE SETUP
// mongoose instance connection url connection
mongoose.Promise = global.Promise;
mongoose.connect(process.env.MONGODB_URI, {
useMongoClient: true
});
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(cors({ credentials: true, origin: true }));
var routes = require('./api/routes/OKrammusRoutes'); //importing route
routes(app); //register the route
app.listen(port, ip);
console.log('OKrammus RESTful API server started on: ' + port);
module.exports = app;
app.use(function (req, res) {
res.status(404).send({ url: req.originalUrl + ' not found' });
});