Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(bot): add HTTP route #852

Merged
merged 13 commits into from
Oct 23, 2022
Merged

Conversation

tschaffter
Copy link
Member

@tschaffter tschaffter commented Oct 17, 2022

Changelog

  • Add dedicated app class.
  • Add custom API endpoints using an Express server and serverless-http.
    • Add path /challenge-bot/ping (/ping is reserved by AWS API Gateway).
  • Simulate serverless deployment with serverless-offline.

Features

Deploy the bot locally in a serverless environment:

vscode@cdaa8ec69ba2:/workspaces/challenge-registry/apps/challenge-bot$ sls offline
Compiling with Typescript...
Using local tsconfig.json - tsconfig.json
Warning: "rootDir" from local tsconfig.json is overriden
Typescript compiled.
Watching typescript files...

Starting Offline at stage dev (us-east-1)

Offline [http for lambda] listening on http://localhost:3002
Function names exposed for local invocation by aws-sdk:
           * challengeBot: challenge-bot-dev-challengeBot
           * ping: challenge-bot-dev-ping

   ┌────────────────────────────────────────────────────────────────────────────────┐
   │                                                                                │
   │   POST | http://localhost:3000/api/github/webhooks                             │
   │   POST | http://localhost:3000/2015-03-31/functions/challengeBot/invocations   │
   │   GET  | http://localhost:3000/challenge-bot/ping                              │
   │   POST | http://localhost:3000/2015-03-31/functions/ping/invocations           │
   │                                                                                │
   └────────────────────────────────────────────────────────────────────────────────┘

Server ready: http://localhost:3000 🚀

Ping the local app:

$ curl -i -X GET http://localhost:3000/challenge-bot/ping
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
content-length: 13
etag: W/"d-NMovXDE1NuzTr1lpmBE8ZRjliFM"
cache-control: no-cache
accept-ranges: bytes
Date: Sun, 23 Oct 2022 00:31:25 GMT
Connection: keep-alive
Keep-Alive: timeout=5

{"pong":true}

Ping the app deployed to AWS:

$ curl -i -X GET https://3p2dbilegi.execute-api.us-east-1.amazonaws.com/challenge-bot/ping
HTTP/2 200 
date: Sun, 23 Oct 2022 00:30:47 GMT
content-type: application/json; charset=utf-8
content-length: 13
etag: W/"d-NMovXDE1NuzTr1lpmBE8ZRjliFM"
apigw-requestid: abqwThDlIAMESdA=

{"pong":true}

@tschaffter tschaffter self-assigned this Oct 17, 2022
@tschaffter tschaffter changed the title feat(bot): scaffold Probot app feat(bot): add HTTP route Oct 18, 2022
@tschaffter tschaffter marked this pull request as ready for review October 23, 2022 00:33
@tschaffter tschaffter merged commit 9f6f596 into Sage-Bionetworks:main Oct 23, 2022
@tschaffter tschaffter deleted the scaffold-probot branch October 23, 2022 00:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Identify how to best scaffold the bot app Add a custom HTTP route to the bot
1 participant