-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
31 lines (22 loc) · 928 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
const express = require('express');
const bodyParser = require('body-parser');
const routes = require('./routes/api');
const mongoose = require('mongoose');
// set up express app
const qbotapp = express();
mongoose.connect('mongodb://qabotdb:ryd5jwE2bpnq4nzTafyV7zHwNqFwKsGet9EQjmZ5b8zvlfY59SlLX9BJO6aHfZi35paKR9mMIUzZc8e7V6YjIA%3D%3D@qabotdb.documents.azure.com:10255/mean-dev?ssl=true&sslverifycertificate=false');
mongoose.Promise = global.Promise;
// so that we can serve static files
qbotapp.use(express.static('public'));
// intlialize body parser middleware
qbotapp.use(bodyParser.json());
// initialize routes to be used by app
qbotapp.use('/api',routes);
// initialize error-handling middleware
qbotapp.use(function(err,req,res,next){
res.status(422).send({error: err.message});
});
// listen for requests
qbotapp.listen(process.env.PORT || 4000,function(){
console.log('now listening for requests');
});