-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
38 lines (31 loc) · 1.15 KB
/
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
//dependencies
var express = require('express');
var bodyParser = require('body-parser');
var methodOverride = require('method-override');
//create the express instance
var app =express();
var port = process.env.PORT || 3000;
// requiring our model for syncing
const env = require('./config/env.js'),
db = require('./config/db.js');
//Serve static content for the app from the "public" directory in the app directory.
app.use(express.static("public"));
app.use(bodyParser.urlencoded({ extended: false}));
//Override with POST having ?_method=DELETE
app.use(methodOverride("_method"));
//set handlebars
var exphbs = require("express-handlebars");
app.engine("handlebars", exphbs({defaultLayout: "main"}));
app.set("view engine", "handlebars");
//Import routes and give the server access to them.
var routes = require("./controllers/airbnb_controller.js");
app.use('/',routes);
app.use("/update",routes);
app.use("/create",routes);
app.use("/delete",routes);
app.use("/weeklycalendar",routes);
app.use("/address",routes);
db.sequelize.sync().then(function() {
app.listen (port);
console.log("server started at : " + port)
});;