JSPM

  • Created
  • Published
  • Downloads 18869
  • Score
    100M100P100Q156902F
  • License MIT

Google recaptcha module for NestJS.

Package Exports

  • @nestlab/google-recaptcha

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@nestlab/google-recaptcha) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Google recaptcha module

Install

$ npm i @nestlab/google-recaptcha

Configuration

@Module({
    imports: [
        GoogleRecaptchaModule.forRoot({
            secretKey: process.env.GOOGLE_RECAPTCHA_SECRET_KEY,
            response: req => req.headers.recaptcha,
            skipIf: req => process.env.NODE_ENV !== 'production',
            onError: () => {
                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!