Skip to content

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

Notifications You must be signed in to change notification settings

KasunJayasanka/serverless-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

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:

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:

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

Deployment

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.

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

License

About

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

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published