Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kasunjayasanka/serverless-api
Deploy a serverless API on AWS with Node.js using the Serverless Framework. This project features RESTful endpoints for retrieving user information, player scores, and creating player scores. It leverages AWS Lambda for serverless compute and DynamoDB for data storage. Get started by configuring your AWS credentials, customizing the serverless.yml
https://github.com/kasunjayasanka/serverless-api
aws aws-dynamodb aws-lambda nodejs serverless-framework
Last synced: about 1 month ago
JSON representation
Deploy a serverless API on AWS with Node.js using the Serverless Framework. This project features RESTful endpoints for retrieving user information, player scores, and creating player scores. It leverages AWS Lambda for serverless compute and DynamoDB for data storage. Get started by configuring your AWS credentials, customizing the serverless.yml
- Host: GitHub
- URL: https://github.com/kasunjayasanka/serverless-api
- Owner: KasunJayasanka
- Created: 2023-12-25T09:27:22.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-27T06:31:14.000Z (about 1 year ago)
- Last Synced: 2023-12-27T07:35:27.842Z (about 1 year ago)
- Topics: aws, aws-dynamodb, aws-lambda, nodejs, serverless-framework
- Language: JavaScript
- Homepage:
- Size: 31.6 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Serverless Framework API Project
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.
## Prerequisites
- [Node.js](https://nodejs.org/) installed
- [Serverless Framework](https://www.serverless.com/) installed (`npm install -g serverless`)
- [AWS CLI](https://aws.amazon.com/cli/) installed and configured with appropriate credentials## Project Structure
- `lambdas/endpoints`: Contains the Lambda functions for different endpoints.
- `serverless.yml`: Configuration file for Serverless Framework.
- `webpack.config.js`: Configuration file for Webpack bundling.## Configuration
### AWS Configuration
Make sure your AWS credentials are configured, and the desired profile is set in the `serverless.yml` file:
```yaml
provider:
name: aws
runtime: nodejs18.x
profile: serverlessUser
stage: dev
region: ap-southeast-1```
### DynamoDB Configuration
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:```yaml
custom:
tableName: player-points
```The DynamoDB table configuration is defined in the `serverless.yml` file under resources:
```yaml
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```
### Deployment
To deploy the API, run the following commands:
```bash
npm install
serverless deploy
```This will deploy the API to AWS Lambda and create the DynamoDB table.
### Endpoints
#### Get User
- Method: `GET`
- Path: `/get-user/{ID}`
- Example: `/get-user/123`#### Get Player Score
- Method: `GET`
- Path: `/get-player-score/{ID}`
- Example: `/get-player-score/456`##### Create Player Score
- Method: `POST`
- Path: `/create-player-score/{ID}`
- Example: `/create-player-score/789`### Dependencies
- [serverless-webpack:](https://www.serverless.com/plugins/serverless-plugin-webpack) Plugin for bundling with Webpack.
### License
- This project is licensed under the [MIT License](https://opensource.org/license/mit/).