mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-13 14:44:43 -04:00
feat: rate-limiting
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
parent
e8f4cbabec
commit
876ebad1f3
10 changed files with 70 additions and 6 deletions
|
@ -7,13 +7,22 @@ const router = module.exports = Router()
|
|||
|
||||
const noteController = require('./controller')
|
||||
const slide = require('./slide')
|
||||
const rateLimit = require('../middleware/rateLimit')
|
||||
const config = require('../../config')
|
||||
|
||||
const applyRateLimitIfConfigured = (req, res, next) => {
|
||||
if (config.rateLimitNewNotes > 0) {
|
||||
return rateLimit.newNotes(req, res, next)
|
||||
}
|
||||
next()
|
||||
}
|
||||
|
||||
// get new note
|
||||
router.get('/new', noteController.createFromPOST)
|
||||
router.get('/new', applyRateLimitIfConfigured, noteController.createFromPOST)
|
||||
// post new note with content
|
||||
router.post('/new', markdownParser, noteController.createFromPOST)
|
||||
router.post('/new', applyRateLimitIfConfigured, markdownParser, noteController.createFromPOST)
|
||||
// post new note with content and alias
|
||||
router.post('/new/:noteId', markdownParser, noteController.createFromPOST)
|
||||
router.post('/new/:noteId', applyRateLimitIfConfigured, markdownParser, noteController.createFromPOST)
|
||||
// get publish note
|
||||
router.get('/s/:shortid', noteController.showPublishNote)
|
||||
// publish note actions
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue