refactor(app.js): Extract history api
This commit is contained in:
parent
c99ae8e1f8
commit
706df11e23
2 changed files with 20 additions and 11 deletions
12
app.js
12
app.js
|
@ -199,18 +199,8 @@ app.set('view engine', 'ejs')
|
||||||
app.use(require('./lib/web/baseRouter'))
|
app.use(require('./lib/web/baseRouter'))
|
||||||
app.use(require('./lib/web/statusRouter'))
|
app.use(require('./lib/web/statusRouter'))
|
||||||
app.use(require('./lib/web/auth'))
|
app.use(require('./lib/web/auth'))
|
||||||
|
app.use(require('./lib/web/historyRouter'))
|
||||||
|
|
||||||
var history = require('./lib/history.js')
|
|
||||||
// get history
|
|
||||||
app.get('/history', history.historyGet)
|
|
||||||
// post history
|
|
||||||
app.post('/history', urlencodedParser, history.historyPost)
|
|
||||||
// post history by note id
|
|
||||||
app.post('/history/:noteId', urlencodedParser, history.historyPost)
|
|
||||||
// delete history
|
|
||||||
app.delete('/history', history.historyDelete)
|
|
||||||
// delete history by note id
|
|
||||||
app.delete('/history/:noteId', history.historyDelete)
|
|
||||||
// get me info
|
// get me info
|
||||||
app.get('/me', function (req, res) {
|
app.get('/me', function (req, res) {
|
||||||
if (req.isAuthenticated()) {
|
if (req.isAuthenticated()) {
|
||||||
|
|
19
lib/web/historyRouter.js
Normal file
19
lib/web/historyRouter.js
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
const Router = require('express').Router
|
||||||
|
|
||||||
|
const {urlencodedParser} = require('./utils')
|
||||||
|
const history = require('../history.js')
|
||||||
|
|
||||||
|
const historyRouter = module.exports = Router()
|
||||||
|
|
||||||
|
// get history
|
||||||
|
historyRouter.get('/history', history.historyGet)
|
||||||
|
// post history
|
||||||
|
historyRouter.post('/history', urlencodedParser, history.historyPost)
|
||||||
|
// post history by note id
|
||||||
|
historyRouter.post('/history/:noteId', urlencodedParser, history.historyPost)
|
||||||
|
// delete history
|
||||||
|
historyRouter.delete('/history', history.historyDelete)
|
||||||
|
// delete history by note id
|
||||||
|
historyRouter.delete('/history/:noteId', history.historyDelete)
|
Loading…
Reference in a new issue