forked from dharness/USC_web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
executable file
·34 lines (26 loc) · 1.13 KB
/
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
// server.js
// set up ======================================================================
// get all the tools we need
var express = require('express')
var app = express()
var port = process.env.PORT || 8080
var bodyParser = require('body-parser')
var methodOverride = require('method-override')
var http = require('http')
var MongoClient = require('mongodb').MongoClient;
// DATBASE CRUMS ======================================
MongoClient.connect('mongodb://usc_admin:[email protected]:31701/usc_web', function(err, db) {
if (err) throw err;
console.log("Connected to Database");
_db = db //this is our global database object
})
app.use(bodyParser.json()) // get information from html forms
app.use(bodyParser.urlencoded({
extended: true
}))
app.use(express.static(__dirname + '/public'))
// routes ======================================================================
require('./app/routes.js')(app) // load our routes and pass in our app and fully configured passport
// launch ======================================================================
app.listen(port)
console.log('The magic happens on port ' + port)