add basic rate limiting
This commit is contained in:
parent
e4200690d9
commit
6a1ef614ad
|
@ -2,6 +2,7 @@ const express = require('express')
|
||||||
const bodyParser = require('body-parser')
|
const bodyParser = require('body-parser')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const favicon = require('serve-favicon')
|
const favicon = require('serve-favicon')
|
||||||
|
const rateLimit = require('express-rate-limit')
|
||||||
|
|
||||||
const crawl = require('./crawler')
|
const crawl = require('./crawler')
|
||||||
const parseHTML = require('./parser')
|
const parseHTML = require('./parser')
|
||||||
|
@ -30,18 +31,13 @@ app.get('/error', (req, res) => {
|
||||||
.render('error', { error })
|
.render('error', { error })
|
||||||
})
|
})
|
||||||
|
|
||||||
app.get('/download', (req, res) => {
|
|
||||||
res
|
|
||||||
.status(200)
|
|
||||||
.render('download')
|
|
||||||
})
|
|
||||||
|
|
||||||
// NOTE: Capture all unkown URLs
|
// NOTE: Capture all unkown URLs
|
||||||
app.get('*', (req, res) => {
|
app.get('*', (req, res) => {
|
||||||
res.status(400).render('404')
|
res.status(400).render('404')
|
||||||
})
|
})
|
||||||
|
|
||||||
app.use('/download', checkFBURL)
|
app.use('/download', checkFBURL)
|
||||||
|
app.use('/download', rateLimit())
|
||||||
app.post('/download', async (req, res) => {
|
app.post('/download', async (req, res) => {
|
||||||
const { url } = req.body
|
const { url } = req.body
|
||||||
|
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<title>Facebook Events to iCal Converter | download</title>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<h2>Your ICS file is ready</h2>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
The <code>ics</code> file was created successfully from url
|
|
||||||
<a href="<%= url %>"><%= url %></a>.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
Your download will start automatically.
|
|
||||||
</p>
|
|
||||||
<a href="/">Go back</a>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -860,6 +860,11 @@
|
||||||
"vary": "~1.1.2"
|
"vary": "~1.1.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"express-rate-limit": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-dhT57wqxfqmkOi4HM7NuT4Gd7gbUgSK2ocG27Y6lwm8lbOAw9XQfeANawGq8wLDtlGPO1ZgDj0HmKsykTxfFAg=="
|
||||||
|
},
|
||||||
"extend": {
|
"extend": {
|
||||||
"version": "3.0.2",
|
"version": "3.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz",
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
"dayjs": "^1.8.16",
|
"dayjs": "^1.8.16",
|
||||||
"ejs": "^2.7.1",
|
"ejs": "^2.7.1",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
|
"express-rate-limit": "^5.0.0",
|
||||||
"ics": "^2.18.0",
|
"ics": "^2.18.0",
|
||||||
"request": "^2.88.0",
|
"request": "^2.88.0",
|
||||||
"serve-favicon": "^2.5.0"
|
"serve-favicon": "^2.5.0"
|
||||||
|
|
Loading…
Reference in New Issue