forked from thorgriffs/make-your-madlibs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
30 lines (22 loc) · 756 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
const express = require("express");
const exphbs = require("express-handlebars");
const app = express();
const PORT = process.env.PORT || 8080;
// Require models for syncing
const db = require("./models");
app.use(express.static("public"));
// Parse application body as JSON
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
// Handlebars routes
app.engine("handlebars", exphbs());
app.set("view engine", "handlebars");
// Serve static content from the "public" directory
app.use(express.static("public"));
// // Invoke routes
const routes = require("./routes/api-routes");
app.use(routes);
// Start server listening
db.sequelize.sync({}).then(() => {
app.listen(PORT, () => console.log(`Listening on PORT ${PORT}`));
});