nest-google-recaptcha
v0.2.0
Published
Google recaptcha module for NestJs.
Downloads
14
Maintainers
Readme
Google recaptcha module
Install
$ npm i nest-google-recaptcha
Configuration
@Module({
imports: [
GoogleRecaptchaModule.forRoot({
secretKey: process.env.GOOGLE_RECAPTCHA_SECRET_KEY,
version: 3, // Optional, for V3
minScore: 0.5, // Optional, for V3
response: req => req.headers.authorization,
skipIf: req => process.env.NODE_ENV !== 'production',
onError: e => {
throw new BadRequestException('Invalid recaptcha.')
}
})
],
})
export class AppModule {
}
Usage
@Controller('feedback')
export class FeedbackController {
@Recaptcha()
@Post('send')
async send(): Promise<any> {
// TODO: Implement it.
}
}
Enjoy!