-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
51 lines (30 loc) · 1.59 KB
/
app.js
File metadata and controls
51 lines (30 loc) · 1.59 KB
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
50
51
const express = require('express')
const app = express()
const bodyParser = require('body-parser')
const userController = require('./controllers/users')
const port = process.env.PORT || 8080
const cookieParser = require('cookie-parser')
const bountyController = require('./controllers/bounty')
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({extended: true}))
app.use(express.static('public'))
app.set('view engine', 'ejs')
app.use(cookieParser())
app.get('/', userController.getHomePage)
app.get('/home', userController.authenticate, userController.getLoggedInPage)
app.get('/login', userController.getLoginPage)
app.get('/register', userController.getRegisterPage)
app.post('/api/register', userController.createUser)
app.post('/api/login', userController.verifyUser)
app.get('/api/logout', userController.logout)
app.get('/bounty-board', userController.authenticate, userController.getBountyBoard)
app.get('/account', userController.authenticate, userController.getAccount)
app.post('/add-bounty', userController.authenticate, bountyController.createBounty)
app.get('/api/get-bounties', userController.authenticate, bountyController.getAllBounties)
app.get('/api/get-user-bounties', userController.authenticate, bountyController.getUsersBounties)
app.post('/api/delete/:id', userController.authenticate, bountyController.deleteBounty)
app.post('/api/update-bounty/:id', userController.authenticate, bountyController.updateBounty)
app.post('/api/claim-bounty/:id', userController.authenticate, bountyController.claimBounty)
app.listen(port, () => {
console.log(`Now listening on port ${port}`)
})