How to Create API Endpoints
WebSockets
- Add an action to the
switchstatement ininfra/lib/lambda/websockets/Main.ts. - In most cases, you can defer to a simple operation in
infra/lib/lambda/DbService.ts. If you have complex business logic, consider creating a new service ininfra/lib/lambdaas needed. - Add unit tests in
infra/tests/lib/lambdato correspond to any added/updated code. - Use
GuesstimatorWebSocketfromfrontend/src/lib/services/websockets.tsto send the new action from the frontend app.
REST
- Add a route in `infra/lib/lambda/rest/Router.ts. Use other cases as an example.
- In most cases, you can defer to a simple operation in
infra/lib/lambda/DbService.ts. If you have complex business logic, consider creating a new service ininfra/lib/lambdaas needed. - Add unit tests in
infra/tests/lib/lambdato correspond to any added/updated code. - Run
deploy-dev.sh. Follow the getting started documentation if this is your first time deploying from your device. - Get the API URL by running
pulumi stack output.- If your router in
Router.tsis/foo/bar, then the url will be something likehttps://lczi8knisx.execute-api.us-east-1.amazonaws.com/stage/foo/bar
- If your router in
- Use
frontend/src/lib/services/rest.tsto call your endpoint from within the frontend app.