forked from wailingnaomi/festiv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·49 lines (41 loc) · 1.41 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
40
41
42
43
44
45
46
47
48
49
require('dotenv').config()
//packages
const ejs = require('ejs')
const express = require('express')
const bodyParser = require('body-parser')
const app = express() //start express application
const login = require('./src/routes/login')
const register = require('./src/routes/register')
const registerPage = require('./src/routes/registerPage')
const home = require('./src/routes/home')
const search = require('./src/routes/searchUser')
const profile = require('./src/routes/profile')
const match = require('./src/routes/likeAndDislike')
const PORT = process.env.PORT || 8000
// Load in mongoose and make connection to database
require('./src/db/mongoose.js')
// Load in model
const User = require('./src/models/users');
(async () => {
// User refers to our User model. We don't have to use db.collection anymore
const users = await User.find({})
})()
app
.set('view engine', 'ejs')
.set('views', 'views')
.use(express.static('static'))
.use('/static', express.static(__dirname + '/static/'))
.use(bodyParser.json())
.use(bodyParser.urlencoded({
extended: true
}))
.use(register)
.use(search)
.get('/', login) // register and login
.get('/register', registerPage)
.get('/home', home) // homepage with all the users
.post('/match', match)
.listen(PORT, () => console.log(`Listening on ${ PORT }`))
function notFound(req, res) {
res.status(404).render('notfound.ejs')
}