-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
39 lines (28 loc) · 928 Bytes
/
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
const http = require("http");
const fs = require("fs");
const util = require("util");
const express = require("express");
const path = require("path");
const logger = require("./middleware/logger");
const app = express();
// Init middleware
// app.use(logger);
// Body Parser Middleware
app.use(express.json())
app.use(express.urlencoded({ extended: false }));
// Set 'public' as static folder
app.use(express.static((path.join(__dirname, "public"))));
// Notes API Routes
app.use("/api/notes", require("./routes/api/notes"));
// HTML Route
app.get("/notes", function (req, res) {
res.sendFile(path.join(__dirname, "./public/notes.html"));
});
app.get("*", function (req, res) {
res.sendFile(path.join(__dirname, "./public/index.html"));
});
const PORT = process.env.PORT || 3000;
// // Starts the server to begin listening
app.listen(PORT, function () {
console.log(`App listening on PORT ${PORT}`);
});