-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
41 lines (29 loc) · 882 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
31
32
33
34
35
36
37
38
39
40
41
const express = require('express')
const app = express()
const ejs = require('ejs')
const expressLayout = require('express-ejs-layouts')
const path = require('path')
const PORT = process.env.PORT || 3000
const { colors } = require('laravel-mix/src/Log')
const mongoose = require('mongoose');
const url = 'mongodb://localhost/pizza';
mongoose.connect(url, {
useNewUrlParser: true,
useUnifiedTopology: true,
});
const connection = mongoose.connection;
connection.once('open', () => {
console.log('Database connected...');
})
.on('error', (error) => {
console.log('Connection error:', error);
});
// Assets
app.use(express.static('public'))
app.use(expressLayout)
app.set('views', path.join(__dirname, '/resources/views'))
app.set('view engine', 'ejs')
require('./routes/web')(app)
app.listen(PORT, () => {
console.log(`Listening on Port ${PORT}`)
})