How to Create API Endpoints
WebSockets
- Add an action to the
switch
statement 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/lambda
as needed. - Add unit tests in
infra/tests/lib/lambda
to correspond to any added/updated code. - Use
GuesstimatorWebSocket
fromfrontend/src/lib/services/websockets.ts
to 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/lambda
as needed. - Add unit tests in
infra/tests/lib/lambda
to 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.ts
is/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.ts
to call your endpoint from within the frontend app.