This replaces the existing project "portfolio-site-api."
This is the code for the API that is used to provide my portfolio site with project data that is ultimately populated into project cards. This creates a Lambda function that connects to an existing DynamoDB table and then exposes its data through an AWS API Gateway. Commented out code in the .yml could also be uncommented and included to create a new DynamoDB table upon deployment.
Run the following command:
- serverless deploy --stage prod
Run the following command:
- serverless remove --stage prod
There are multiple ways to test this app.
DEV - The first involves using the Serverless-Offline plugin along with a live dynamoDB (can be dev or prod; not currently doing writes).
- npm install
- serverless offline start --stage dev (or "npm run start-dev)
- test the endpoints using "npm run test"
PROD - After deploying, run the following from AWS CLI to verify the service is up and running (in addition to the Jest unit/ integration tests):
- aws apigateway test-invoke-method --rest-api-id (api id here) --resource-id (resource id here) --http-method (method here - 'GET', 'POST', etc.)
You can use the following to obtain info on your service:
- serverless info
- aws apigateway get-resources --rest-api-id (api ID here)
The API ID can be obtained using serverless info above. It will provide you with your AWS endpoints. In the URL, the text after https:// is your API ID. (i.e. https://caufjc1cde.execute-api.us-east-1.amazonaws.com/dev/projects --> caufjc1cde is the API ID). Then use the get-resources AWS command to obtain your resource-id