-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathserver.js
More file actions
36 lines (25 loc) · 1004 Bytes
/
server.js
File metadata and controls
36 lines (25 loc) · 1004 Bytes
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
let express = require('express');
let PORT = process.env.PORT || 8080;
let app = express();
var db = require("./models");
// Parse application body as JSON
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
// Set Handlebars.
let exphbs = require('express-handlebars');
app.engine('handlebars', exphbs({ defaultLayout: 'main' }));
app.set('view engine', 'handlebars');
// Serve static content for the app from the 'public' directory in the application directory.
app.use(express.static('public'));
// Import routes and give the server access to them.
//const routes = require('./routes/api-routes')
const routes = express.Router()
require('./routes/html-api-routes.js')(routes)
app.use('/', routes);
// Start our server so that it can begin listening to client requests.
db.sequelize.sync().then(function() {
app.listen(PORT, function () {
// Log (server-side) when our server has started
console.log('Server listening on: http://localhost:' + PORT);
});
});