Skip to content

Commit 706df11

Browse files
committed
refactor(app.js): Extract history api
1 parent c99ae8e commit 706df11

2 files changed

Lines changed: 20 additions & 11 deletions

File tree

app.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -199,18 +199,8 @@ app.set('view engine', 'ejs')
199199
app.use(require('./lib/web/baseRouter'))
200200
app.use(require('./lib/web/statusRouter'))
201201
app.use(require('./lib/web/auth'))
202+
app.use(require('./lib/web/historyRouter'))
202203

203-
var history = require('./lib/history.js')
204-
// get history
205-
app.get('/history', history.historyGet)
206-
// post history
207-
app.post('/history', urlencodedParser, history.historyPost)
208-
// post history by note id
209-
app.post('/history/:noteId', urlencodedParser, history.historyPost)
210-
// delete history
211-
app.delete('/history', history.historyDelete)
212-
// delete history by note id
213-
app.delete('/history/:noteId', history.historyDelete)
214204
// get me info
215205
app.get('/me', function (req, res) {
216206
if (req.isAuthenticated()) {

lib/web/historyRouter.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
'use strict'
2+
3+
const Router = require('express').Router
4+
5+
const {urlencodedParser} = require('./utils')
6+
const history = require('../history.js')
7+
8+
const historyRouter = module.exports = Router()
9+
10+
// get history
11+
historyRouter.get('/history', history.historyGet)
12+
// post history
13+
historyRouter.post('/history', urlencodedParser, history.historyPost)
14+
// post history by note id
15+
historyRouter.post('/history/:noteId', urlencodedParser, history.historyPost)
16+
// delete history
17+
historyRouter.delete('/history', history.historyDelete)
18+
// delete history by note id
19+
historyRouter.delete('/history/:noteId', history.historyDelete)

0 commit comments

Comments
 (0)