Skip to content

Commit 689bade

Browse files
committed
refactor(app.js): Extract note action
1 parent e2ac73f commit 689bade

2 files changed

Lines changed: 28 additions & 17 deletions

File tree

app.js

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -280,23 +280,10 @@ app.post('/uploadimage', function (req, res) {
280280
}
281281
})
282282
})
283-
// get new note
284-
app.get('/new', response.newNote)
285-
// get publish note
286-
app.get('/s/:shortid', response.showPublishNote)
287-
// publish note actions
288-
app.get('/s/:shortid/:action', response.publishNoteActions)
289-
// get publish slide
290-
app.get('/p/:shortid', response.showPublishSlide)
291-
// publish slide actions
292-
app.get('/p/:shortid/:action', response.publishSlideActions)
293-
// get note by id
294-
app.get('/:noteId', response.showNote)
295-
// note actions
296-
app.get('/:noteId/:action', response.noteActions)
297-
// note actions with action id
298-
app.get('/:noteId/:action/:actionId', response.noteActions)
299-
// response not found if no any route matches
283+
284+
app.use(require('./lib/web/noteRoute'))
285+
286+
// response not found if no any route matxches
300287
app.get('*', function (req, res) {
301288
response.errorNotFound(res)
302289
})

lib/web/noteRouter.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
'use strict'
2+
3+
const Router = require('express').Router
4+
5+
const response = require('../response')
6+
7+
const noteRouter = module.exports = Router()
8+
9+
// get new note
10+
noteRouter.get('/new', response.newNote)
11+
// get publish note
12+
noteRouter.get('/s/:shortid', response.showPublishNote)
13+
// publish note actions
14+
noteRouter.get('/s/:shortid/:action', response.publishNoteActions)
15+
// get publish slide
16+
noteRouter.get('/p/:shortid', response.showPublishSlide)
17+
// publish slide actions
18+
noteRouter.get('/p/:shortid/:action', response.publishSlideActions)
19+
// get note by id
20+
noteRouter.get('/:noteId', response.showNote)
21+
// note actions
22+
noteRouter.get('/:noteId/:action', response.noteActions)
23+
// note actions with action id
24+
noteRouter.get('/:noteId/:action/:actionId', response.noteActions)

0 commit comments

Comments
 (0)