diff --git a/serverless-uncompiled.yml b/serverless-uncompiled.yml index 8bbf27958..dfab65d3f 100644 --- a/serverless-uncompiled.yml +++ b/serverless-uncompiled.yml @@ -939,14 +939,14 @@ functions: method: post cors: ${{self:custom.cors}} - # documentChecker: - # handler: lib/in-house-bot/lambda/http/documentChecker-webhook.handler - # memorySize: 1024 - # events: - # - http: - # path: documentChecker - # method: post - # cors: ${{self:custom.cors}} + documentChecker: + handler: lib/in-house-bot/lambda/http/documentChecker-webhook.handler + memorySize: 1024 + events: + - http: + path: documentChecker + method: post + cors: ${{self:custom.cors}} # documentChecker: # handler: lib/in-house-bot/lambda/document-checker-job.handler diff --git a/src/in-house-bot/lambda/http/documentChecker-webhook.ts b/src/in-house-bot/lambda/http/documentChecker-webhook.ts new file mode 100644 index 000000000..590c4e374 --- /dev/null +++ b/src/in-house-bot/lambda/http/documentChecker-webhook.ts @@ -0,0 +1,34 @@ +import compose from 'koa-compose' +import cors from 'kcors' +import { configureLambda } from '../..' +import { post } from '../../../middleware/noop-route' +import Errors from '../../../errors' +import * as LambdaEvents from '../../lambda-events' +import { fromHTTP } from '../../lambda' + +const lambda = fromHTTP({ + event: LambdaEvents.DOCUMENT_CHECKER_WEBHOOK_EVENT, + preware: compose([ + post(), + cors(), + ]) +}) + +lambda.use(async (ctx) => { + debugger + const { documentChecker } = ctx.components + if (!documentChecker) { + throw new Errors.HttpError(404, 'not found') + } + + const { event } = ctx + try { + await documentChecker.handleVerificationEvent(event) + } catch (err) { + lambda.logger.error('failed to handle documentChecker webhook call', err) + ctx.status = 500 + ctx.error = new Error('failed') + } +}) + +export const handler = lambda.handler