-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
42 lines (28 loc) · 873 Bytes
/
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
40
41
42
require('dotenv').config()
const express = require('express')
const mongoose = require('mongoose')
const post = require('./routers/post')
const category = require('./routers/category')
const admin = require('./routers/admin')
const base = require('./routers/base')
const app = express()
const port = process.env.PORT
app.use(express.static(__dirname + '/public'));
// set the view engine to ejs
app.set('view engine', 'ejs');
// for request json and body
app.use(express.json())
app.use(express.urlencoded())
// for mongoose uri connection
mongoose.connect(process.env.URI)
.then(()=>{
console.log('Database succesfully connected...')
})
.catch(error => handleError(error));
app.use('/',base)
app.use('/admin',admin)
app.use('/post',post)
app.use('/category',category)
app.listen(port,()=>{
console.log(`Server running at http://localhost:${port}`)
})