This project uses the Serverless Framework to deploy a serverless API on AWS with Node.js 18.x runtime. It includes endpoints to get user information, retrieve player scores, and create player scores.
- Node.js installed
- Serverless Framework installed (
npm install -g serverless
) - AWS CLI installed and configured with appropriate credentials
lambdas/endpoints
: Contains the Lambda functions for different endpoints.serverless.yml
: Configuration file for Serverless Framework.webpack.config.js
: Configuration file for Webpack bundling.
Make sure your AWS credentials are configured, and the desired profile is set in the serverless.yml
file:
provider:
name: aws
runtime: nodejs18.x
profile: serverlessUser
stage: dev
region: ap-southeast-1
A DynamoDB table named player-points
will be created with the necessary configuration.
You can change the table name in the serverless.yml
file under custom:
custom:
tableName: player-points
The DynamoDB table configuration is defined in the serverless.yml
file under resources:
resources:
Resources:
MyDynamoDbTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:custom.tableName}
AttributeDefinitions:
- AttributeName: ID
AttributeType: S
KeySchema:
- AttributeName: ID
KeyType: HASH
BillingMode: PAY_PER_REQUEST
To deploy the API, run the following commands:
npm install
serverless deploy
This will deploy the API to AWS Lambda and create the DynamoDB table.
- Method:
GET
- Path:
/get-user/{ID}
- Example:
/get-user/123
- Method:
GET
- Path:
/get-player-score/{ID}
- Example:
/get-player-score/456
- Method:
POST
- Path:
/create-player-score/{ID}
- Example:
/create-player-score/789
- serverless-webpack: Plugin for bundling with Webpack.
- This project is licensed under the MIT License.