-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathserver.js
54 lines (39 loc) · 1.49 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* ================== SERVER ================== */
// DEPENDENCIES
// =============================================================
var express = require("express");
// var mongoose = require("mongoose");
var path = require("path");
var bodyParser = require("body-parser");
// EXPRESS APP
// =============================================================
var app = express();
var PORT = process.env.PORT || 3000;
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.text());
app.use(bodyParser.json({ type: "application/vnd.api+json" }));
// set up static directory 'public'
app.use("/public", express.static("./public"));
// MONGODB CONFIGURATION
// =============================================================
// mongodb local connection
// mongoose.connect("mongodb://localhost/myclubsdb", {
// useMongoClient: true});
// heroku mongolab connection
// mongoose.connect("mongodb://heroku_v0vqth9z:[email protected]:55414/heroku_v0vqth9z");
// var db = mongoose.connection;
// db.on("error", function(err){
// console.log("Mongoose Error: ", err);
// });
// db.once("open", function(){
// console.log("Mongoose connection successful.");
// });
// EXPRESS APP ROUTES
// =============================================================
require("./routes/api-routes.js")(app);
// START LISTENER
// =============================================================
app.listen(PORT, function(){
console.log("App listening on PORT " + PORT);
});