-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
executable file
·35 lines (28 loc) · 992 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
"use strict";
var express = require('express');
var app = express();
var port = process.env.PORT || 3000;
var bodyParser = require('body-parser');
var apiRouter = require('./routes/api');
// middleware
app.use(express.static(__dirname + '/app'));
app.use(express.static(__dirname)); // include bower_components
app.use(bodyParser.json());
// mongoose + mongoose schemas
var mongoose = require('mongoose');
//export MONGOLAB_URI="mongodb://admin:[email protected]:19678/heroku_5d24197s"
var db = "mongodb://admin:[email protected]:19678/heroku_5d24197s";
//var db = 'mongodb://localhost/baseballdb';
mongoose.connect(db, function(err) {
if (err) {
console.log("couldn't connect to mongodb!");
console.log(err);
} else {
console.log("connected to mongodb successfull!");
}
});
app.disable('x-powered-by'); // security
app.use('/api', apiRouter);
app.listen(port, function () {
console.log('Server listening on port ' + port + "!");
});