forked from zaidm124/Voter-WebApp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
39 lines (32 loc) · 1013 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
39
require("dotenv").config();
const mongoose = require("mongoose");
const express = require("express");
const app = express();
const path = require("path");
app.use(express.static(path.join(__dirname, "client/build")));
const hostname = "http://127.0.0.1";
app.use(express.json());
app.use(express.static("public"));
const Todo = require("./model/userSchema");
const PORT = process.env.PORT || 5000;
require("./DB/conn");
app.use(require("./router/auth"));
const middleware = (req, res, next) => {
cosole.log("Hello my middle ware");
next();
};
// Todo.deleteOne({ title: "a" }, function (err) {
// if (err) return handleError(err);
// });
// app.get("/", (req, res) => {
// res.send("hello from server app.js");
// });
app.get("/*", (req, res) => {
res.sendFile(path.join(__dirname, "client/build", "index.html"));
});
if (process.env.NODE_ENV === "production") {
app.use(express.static("client/build"));
}
app.listen(PORT, () => {
console.log(`Server is running at ${hostname}:${PORT}`);
});