Skip to content

Commit

Permalink
feat: Keesing WebAPI project
Browse files Browse the repository at this point in the history
  • Loading branch information
pgmemk committed Oct 9, 2018
1 parent bb1ebe6 commit 2a5b6f7
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 8 deletions.
16 changes: 8 additions & 8 deletions serverless-uncompiled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 34 additions & 0 deletions src/in-house-bot/lambda/http/documentChecker-webhook.ts
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 2a5b6f7

Please sign in to comment.