-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
39 lines (33 loc) · 1.14 KB
/
index.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
const dotenv = require(`dotenv`);
const express = require(`express`);
const bodyParser = require(`body-parser`);
const hbs = require(`hbs`);
const handlebars_helper = require(`./views/handlebars-helper.js`);
const routes = require(`./routes/routes.js`);
const mongoose = require(`mongoose`);
const session = require('express-session');
const MongoStore = require(`connect-mongo`);
const db = require(`./models/db.js`);
const app = express();
app.use(bodyParser.urlencoded({ extended: false }));
app.set(`view engine`, `hbs`);
hbs.registerPartials(__dirname + `/views/partials`);
app.use(express.static(`public`));
app.use(session({
secret: `writers-kiln-session`,
resave: false,
saveUninitialized: false,
store: MongoStore.create({mongoUrl: process.env.DB_URL})
}));
app.use(`/`, routes);
dotenv.config();
// port = process.env.PORT;
// hostname = process.env.HOSTNAME;
db.connect();
// app.listen(port, hostname, function() {
// console.log(`Server running at:`);
// console.log(`http://` + hostname + `:` + port);
// });
app.listen(process.env.PORT || 3000, function() {
console.log(`Server running at Port ` + process.env.PORT);
});