@otterhttp/ip-filter
v3.1.0
Published
tinyhttp IP filtering middleware
Downloads
9
Maintainers
Readme
@otterhttp/ip-filter
IP Filtering middleware to send 403 on bad IPs.
Install
pnpm i @otterhttp/ip-filter
API
import { ipFilter } from '@otterhttp/ip-filter'
ipFilter(options)
Returns the IP filter middleware.
Options
ip
- IP to use. Defaults toreq.ip
strict
: throw if invalid IPfilter
: blacklist filter (array of strings / RegExps)forbidden
: custom 403 message response
Example
import { App } from '@otterhttp/app'
import { ipFilter } from '@otterhttp/ip-filter'
const app = new App()
app.use(ipFilter({ forbidden: 'Get the f*ck out of my server!', filter: [`*.example.com`], strict: true }))
app.get('/', (req, res) => {
res.send('Hello World!')
})
app.listen(3000)