Giter Site home page Giter Site logo

aws-cdk_typescript_crud_template's Introduction

Typescript AWS CDK todo(ish) api

Infrastructure as code framework used: AWS CDK AWS Services used: AWS Lambda, AWS DynamoDB

Summary of the api

In this setup, you can sign up, verify, and login using Amazon Cognito. Additionally, you can create, read, update, and delete to-do tasks using the API.

Given more time, I would have implemented the following features to improve the application:

  • Magic links for account verification
  • Rate limiting using API keys
  • More comprehensive models for data storage
  • A comprehensive suite of tests to ensure the stability and reliability of the application
  • Detailed documentation, including an OpenAPI specification for generating the API automatically
  • A security audit to identify and mitigate any potential vulnerabilities.
  • A Better access control pattern, I'm sure there is a better pattern for resticting users to only there todo's with dynmodb

Requirements

  • AWS CLI already configured with Administrator permission
  • AWS CDK - v2
  • NodeJS 14.x installed
  • CDK bootstrapped in your account

Deploy this demo

Deploy the project to the cloud:

cdk synth
cdk deploy

When asked about functions that may not have authorization defined, answer (y)es. The access to those functions will be open to anyone, so keep the app deployed only for the time you need this demo running.

To delete the app:

cdk destroy

Endpoints

/signup

This endpoint creates a new user in the Cognito user pool.

Method: POST

Request Body:

  • email (string): email of the user
  • password (string): password of the user
  • username (string): username of the user

Response:

  • message (string): Descriptive message about the outcome of the request

/login

This endpoint logs in an existing user and returns a JWT.

Method: POST

Request Body:

  • email (string): email of the user
  • password (string): password of the user

Response:

  • message (string): Descriptive message about the outcome of the request
  • token (string): JWT for the authenticated user

/verify?code={awsCode}&username={userame}

This endpoint verifies a user using a AWS verification code sent to the user by email.

Method: GET

Request Query parameters:

  • code (string): Aws confirmation code
  • username (string): Username of the account to verify

Response:

  • message (string): Descriptive message about the outcome of the request

/todo_tasks

This endpoint is used to manage to-do tasks.

Method:

  • GET: Retrieve all tasks for the authenticated user
  • POST: Create a new task for the authenticated user

/todo_tasks/{taskId}

  • PUT: Update an existing task for the authenticated user
  • DELETE: Delete a task for the authenticated user
  • GET: Retrieve a single task for the authenticated user

Request Body (POST and PUT only):

  • taskDetails (string): Description of the task
  • taskCompleted (Boolean): Task completion status

Response:

  • message (string): Descriptive message about the outcome of the request
  • data (list of tasks): List of tasks for the authenticated user

Authentication The API uses Amazon Cognito to authenticate users. Requests to the API must include a valid JWT in the Authorization header.

AWS CDK useful commands

  • npm run build compile typescript to js
  • npm run watch watch for changes and compile
  • npm run test perform the jest unit tests (still to write)
  • cdk deploy deploy this stack to your default AWS account/region
  • cdk diff compare deployed stack with current state
  • cdk synth emits the synthesized CloudFormation template

aws-cdk_typescript_crud_template's People

Contributors

theodore-q avatar

Stargazers

Ali Clark avatar am elemara avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.