-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
25 lines (20 loc) · 692 Bytes
/
server.js
File metadata and controls
25 lines (20 loc) · 692 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
if (process.env.NODE_ENV !=='production') {
require('dotenv').config()
}
const express = require('express')
const app = express()
const expressLayouts = require('express-ejs-layouts')
const indexrouter = require('./routes/index')
app.set('view engine','ejs')
app.set('views' , __dirname + '/views');
app.set('layout', 'layouts/layout')
app.use(expressLayouts);
app.use(express.static('public'))
app.use('/', indexrouter)
const mongoose = require('mongoose')
mongoose.connect(process.env.DATABASE_URL
)
const db = mongoose.connection;
db.on('error',error => console.error(error))
db.once('open', () => console.log('connected to Mongoose'))
app.listen(process.env.PORT || 3000) ;