@verifiedvisitors/integration-node
v1.0.2
Published
Express middleware for integrating visitor access control with an express application
Downloads
5
Maintainers
Readme
Verified Visitors | Express Integration
NodeJS Express integration module for VerifiedVisitors.
Related documentation
- https://docs.verifiedvisitors.com/integrations
Usage
Prerequisites
- An active VerifiedVisitors account
- An API token generated via the "add site (manual)" flow or the Manage Profile page.
Installation and usage
npm i @verifiedvisitors/integration-node
This module can be used as ExpressJS middleware:
import VerifiedVisitors from '@verifiedvisitors/integration-node'
const vvInstance = new VerifiedVisitors(API_TOKEN, APPLICATION_HOST, {
port: 8080,
protocol: 'http',
})
server.use(vvInstance.middleware)
Client-side JS agent
VerifiedVisitors integrations require the deployment of the client-side JS agent to display challenge pages and extract additional telemetry from user agents. See see our documentaion for more information.
Events
You may add event listeners to the following events we emit:
allow
,block
,captcha
, andjs_challenge
- provides therequest
andresponse
objects to a callback you assign.error
- provides the error object to a callback you assign
An example:
import VerifiedVisitors from '@verified-visitors/express-integration'
import { type Request, type Response } from 'express'
const vvInstance = new VerifiedVisitors(
VV_TOKEN, APPLICATION_HOST, { port: 8080, protocol: 'http' }
)
.on('block', (request: Request, response: Response) => {
console.log(`Blocked ip: ${request.ip} from accessing ${request.url}. Returned ${response.statusCode}`)
})
.on('error', (e: Error) => console.error(`Error caught: ${e}`))
server.use(vvInstance.middleware)