From ce576dea8fe3356e919723f71d7ea09d378f3bea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Acid=20Chicken=20=28=E7=A1=AB=E9=85=B8=E9=B6=8F=29?= Date: Sun, 3 Feb 2019 22:21:55 +0900 Subject: [PATCH] Create type definition for 'recaptcha-promise' (#4068) --- src/@types/recaptcha-promise.d.ts | 16 ++++++++++++++++ src/server/api/private/signup.ts | 3 +-- 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 src/@types/recaptcha-promise.d.ts diff --git a/src/@types/recaptcha-promise.d.ts b/src/@types/recaptcha-promise.d.ts new file mode 100644 index 000000000..cfbd5eebf --- /dev/null +++ b/src/@types/recaptcha-promise.d.ts @@ -0,0 +1,16 @@ +declare module 'recaptcha-promise' { + interface IVerifyOptions { + secret_key?: string; + } + + interface IVerify { + (response: string, remoteAddress?: string): Promise; + init(options: IVerifyOptions): IVerify; + } + + namespace recaptchaPromise {} // Hack + + const verify: IVerify; + + export = verify; +} diff --git a/src/server/api/private/signup.ts b/src/server/api/private/signup.ts index b89629bcd..6318eabdb 100644 --- a/src/server/api/private/signup.ts +++ b/src/server/api/private/signup.ts @@ -8,14 +8,13 @@ import Meta from '../../../models/meta'; import RegistrationTicket from '../../../models/registration-tickets'; import usersChart from '../../../chart/users'; import fetchMeta from '../../../misc/fetch-meta'; +import * as recaptcha from 'recaptcha-promise'; export default async (ctx: Koa.BaseContext) => { const body = ctx.request.body as any; const instance = await fetchMeta(); - const recaptcha = require('recaptcha-promise'); - // Verify recaptcha // ただしテスト時はこの機構は障害となるため無効にする if (process.env.NODE_ENV !== 'test' && instance.enableRecaptcha) {