Skip to content

jostrander/nest-google-recaptcha

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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!

About

Google recaptcha module for nestjs

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •