-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
43 lines (31 loc) · 1.12 KB
/
app.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
const express = require("express");
const bodyParser = require("body-parser");
const path = require('path');
const logger = require("morgan");
const mongojs = require("mongojs");
const mongoose = require("mongoose");
const app = express();
// =============================================================
// Middleware
app.use(bodyParser.urlencoded({extended: false}));
app.use(bodyParser.json());
app.use(logger("dev"));
app.use(express.static( path.join(__dirname, "src", "client") ));
// =============================================================
// API Endpoint Routes
const api = require("./src/server/api");
app.use("/api", api);
// =============================================================
// Views
app.get("*", function(req, res){
res.sendFile( path.join(__dirname, "src", "client", "index.html") );
});
// =============================================================
// Starting Server
const PORT = process.env.PORT || 3000;
app.listen(PORT, function() {
console.log("App running on port " + PORT);
});
// =============================================================
// Export App for Testing
module.exports = app;