-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
41 lines (32 loc) · 957 Bytes
/
server.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
//Basic express app for running server
const express = require("express");
const port = process.env.PORT || 5000;
const connectDB = require("./config/db");
const path = require("path");
const app = express();
//Connect to Database
pool = connectDB();
pool.connect();
//TODO: Add api routes
//app.get("/", (req, res) => res.send("Hello world"));
//Will use static assests in a production environment
if (process.env.NODE_ENV == "production") {
app.use(express.static("client/build"));
//TODO: remove this
app.get("/", (req, res) => res.send("Hello world"));
app.get("*", (req, res) => {
res.sendFile(path.resolve(_dirname, "client", "build", "index.html"));
});
}
app.listen(port, () =>
console.log(`Example app listening at http://localhost:${port}`)
);
pool.query("SELECT * FROM person", (err, res) => {
if (err) {
console.log(err.stack);
console.log("HERE");
} else {
console.log(res.rows[0]);
}
});
pool.end();