Skip to content

A simple demonstration of performing CRUD operations on DynamoDB using Node.js, TypeScript, and AWS SDK v3.

Notifications You must be signed in to change notification settings

danielbrazrocha/node-ts-dynamodb-crud

Repository files navigation

DynamoDB CRUD Operations with Node.js and AWS SDK v3

TypeScript Node.js AWS SDK v3 ESLint

A simple demonstration of performing CRUD operations on DynamoDB using Node.js, TypeScript, and AWS SDK v3.

Table of Contents

Introduction

This project provides a practical example of performing CRUD (Create, Read, Update, Delete) operations on DynamoDB using Node.js, TypeScript, and the AWS SDK v3. It aims to showcase how to interact with DynamoDB for database operations and serve as a reference for integrating DynamoDB into your TypeScript applications.

Features

  • Create and Delete a DynamoDB table
  • Insert items into the table
  • Retrieve items from the table
  • Update items in the table
  • Delete items from the table

Prerequisites

  • Node.js (v14.17.5 or higher)
  • npm (Node Package Manager)
  • AWS CLI
  • Docker

Technologies

Getting Started

To run this project locally, follow these steps:

  1. Clone the repository:

    git clone https://github.com/danielbrazrocha/node-ts-dynamodb-crud.git
  2. Install the dependencies:

    cd node-ts-dynamodb-crud
    npm install
  3. Configure AWS credencials locally

    aws configure

    Use this simple configuration:

  • AWS Access Key ID: anyid
  • AWS Secret Access Key: anykey
  • Default region name: local
  1. Start a DynamoDB Local instance using Docker:

    docker run -p 8000:8000 amazon/dynamodb-local

    Note: Consider creating a Dockerfile for streamlined setup in the future.

  2. Install and run DynamoDB Admin to view database changes:

    npm install -g dynamodb-admin

Running the Project

  1. Ensure the DynamoDB Local container is running.

  2. Create the DynamoDB table:

    npm run create-table
  3. Seed the table with initial data:

    npm run seed
  4. Start the application:

    npm run start

Testing the Application

Once the project is up and running, you can access the following endpoints:

Additional npm Commands

For convenience, the following CRUD commands are available to test in the package.json file:

  • Create: npm run put-item
  • Read: npm run get-item or npm run get-item-by-pk or get-all-items
  • Update: npm run update-item
  • Delete: npm run delete-item

Feel free to explore and modify these commands as needed.

Acknowledgement

Special thanks to James Hamann for the article and the AWS SDK v2 code base, which served as a reference for creating the v3 implementation with TypeScript. You can find the article here and the repository here

About

A simple demonstration of performing CRUD operations on DynamoDB using Node.js, TypeScript, and AWS SDK v3.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published