Skip to content

suud/network-state-backend-aws

Repository files navigation

network-state-backend-aws

Deploy an API that can only be accessed by users holding your token.

Auth Flow

This repository contains an AWS CDK Stack that deploys the AWS Cognito and Network State API resources of the sequence diagram. Have a look at suud/network-state-example-app-react for an implementation of the other parts.

Learn more about the motivation behind this repository by reading this article.

Prerequisites

If you are using AWS CDK for the first time, check out the Introduction to the CDK workshop.

Usage

# clone repository
git clone [email protected]:suud/network-state-backend-aws.git
cd network-state-backend-aws

# install dependencies
npm install
cd lambda-layers/web3/nodejs
npm install
cd ../../..

# compile typescript to js
npm run build

# deploy stack
cdk deploy \
    --parameters rpcUrl=... \
    --parameters contractAddress=... \
    --parameters tokenId=...

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
  • 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