A Nuxt module for SignupGate.
Install the module to your Nuxt application with one command:
npx nuxi module add nuxt-signupgate
That's it! You can now use Nuxt SignupGate in your Nuxt app ✨
The module requires the following environment variable to be set:
NUXT_PRIVATE_SIGNUP_GATE_API_KEY - Your SignupGate API key (required)You can set this in your .env file:
NUXT_PRIVATE_SIGNUP_GATE_API_KEY=your_api_key_here
Configure the module in your nuxt.config.ts:
export default defineNuxtConfig({
modules: ['nuxt-signupgate'],
signupGate: {
// Configure at which risk level the signup gate should be triggered
// Options: 'low' | 'medium' | 'high' | 'none'
// Default: 'high'
riskLevel: 'high'
}
})
riskLevel (default: 'high') - Configure at which risk level the signup gate should block requests:
'high' - Only block high-risk subjects'medium' - Block medium and high-risk subjects'low' - Block low, medium, and high-risk subjects'none' - Don't block any subjects (monitoring only)The module exposes a server-side helper checkRiskLevel which is auto-imported and available in your server routes (no import required). Use this when you want to call SignupGate from server middleware or API routes directly.
q) — must be a non-empty string (email, domain or IP).riskLevel.subject, subjectType, and riskLevel when successful.Example server route using the auto-imported helper:
export default defineEventHandler(async (event) => {
// no import required — `checkRiskLevel` is auto-imported by the module
const q = 'example@domain.com'
const result = await checkRiskLevel(event, q)
// result -> { subject: string, subjectType: string, riskLevel: 'none'|'low'|'medium'|'high' }
return result
})
If you want to check the risk level of the request's IP address, you can use the getRequestIP helper from h3 to get the IP from the request and pass it to checkRiskLevel:
export default defineEventHandler(async (event) => {
const ip = getRequestIP(event)
if (ip) {
await checkRiskLevel(event, ip)
}
})
If you want to check the risk level of the request's referer domain, you can use the getRequestHeader helper from h3 to get the referer header and pass it to checkRiskLevel:
export default defineEventHandler(async (event) => {
const referer = getRequestHeader(event, 'referer')
if (referer) {
await checkRiskLevel(event, referer)
}
})
For client-side calls (from components or composables), continue to use the provided API endpoint GET /api/signupgate/check which performs the same check server-side for you. Example:
const { data, error } = await useFetch('/api/signupgate/check', {
query: { q: 'example@domain.com' }
})
# Install dependencies
npm install
# Generate type stubs
npm run dev:prepare
# Develop with the playground
npm run dev
# Build the playground
npm run dev:build
# Run ESLint
npm run lint
# Run Vitest
npm run test
npm run test:watch
# Release new version
npm run release