-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
34 lines (28 loc) · 1.04 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
const express = require("express");
const mongoose = require("mongoose");
const bp = require("body-parser");
// Models
const Todo = require("./models/todo");
// Express Configuration
const app = express()
app.use(express.static(__dirname + "/public"));
app.use(express.static(__dirname + "/views"));
app.use(bp.urlencoded({extended: true}));
// Globals ------------------------------------------------------
const port = 3000;
// ==============================================================
// ROUTES
// ==============================================================
const apiRoutes = require("./routes/todos");
app.get("/", (req, res) => {
res.sendFile("index.html");
});
app.use("/api/todos", apiRoutes);
// Default ------------------------------------------------------
app.get("*", (req, res) => {
res.redirect("/");
});
// ==============================================================
// START/LISTEN
// ==============================================================
app.listen(port, () => { console.log(`Listening on port ${port}`); });