-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
38 lines (29 loc) · 966 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
// Libraries something
const express = require('express')
const expressLayouts = require('express-layouts')
const app = express()
const PORT = process.env.PORT || 3000
require('dotenv/config')
//Connect to Mongo
const mongoose = require('mongoose')
mongoose.connect(process.env.DB_CONNECTION,{useUnifiedTopology: true, useNewUrlParser: true},
() => console.log('~'))
//EJS
app.use(expressLayouts)
app.set('view engine','ejs')
app.set('views', __dirname + '/views')
app.set('layout', 'layouts/layout')
app.use(express.static(__dirname + '/public'));
//Middleware
app.use(express.json())
//Body Parser
app.use(express.urlencoded({extended:false}))
//Routes
const indexRoute = require('./routes/index')
const usersRoute = require('./routes/users')
const profileRoute = require('./routes/profile')
//Route INIT
app.use('/', indexRoute)
app.use('/users', usersRoute)
app.use('/',profileRoute)
app.listen(PORT, console.log(`Server Started on Port ${PORT}`))