1
0
mirror of https://github.com/comatory/fb2iCal synced 2025-06-05 22:09:25 +02:00

allow passing FB event number as parameter

This commit is contained in:
Ondrej Synacek
2019-10-22 20:25:09 +02:00
parent 97317aeaa4
commit acebfe3658
8 changed files with 78 additions and 31 deletions

View File

@ -7,7 +7,7 @@ const rateLimit = require('express-rate-limit')
const crawl = require('./crawler')
const parseHTML = require('./parser')
const generateICS = require('./ics')
const { genericErrorHandler, checkFBURL } = require('./middlewares')
const { genericErrorHandler, checkURLParameter } = require('./middlewares')
const port = process.env.PORT
const app = express()
@ -36,9 +36,9 @@ app.get('*', (req, res) => {
res.status(400).render('404')
})
app.use('/download', checkFBURL)
app.use('/download', checkURLParameter)
app.use('/download', rateLimit())
app.post('/download', async (req, res) => {
app.post('/download', async (req, res, next) => {
const { url } = req.body
try {
@ -52,7 +52,8 @@ app.post('/download', async (req, res) => {
.send(200, new Buffer(ics, 'utf8'))
}
} catch (err) {
return next(err)
next(err)
return
}
})