-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
37 lines (28 loc) · 924 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
32
33
34
35
36
37
const express = require("express");
const bodyParser = require("body-parser");
const cors = require("cors");
const db = require( './database' );
const path = require( 'path' );
db.manageUser.getFrom.username(null);
const app = express();
// For prod only
// var corsOptions = {
// origin: "http://localhost:8081"
// };
app.use(cors());
// parse requests of content-type - application/json
app.use(bodyParser.json());
// parse requests of content-type - application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: true }));
// simple route
app.set("view engine", "pug");
app.set("views", path.join(__dirname, "documentation/pug"));
app.get("/", (req, res) => {
res.json({ message: "Wazaaaaa." });
});
app.use('/api', require( './router' ));
// set port, listen for requests
const PORT = process.env.PORT || 8080;
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}.`);
});