testnet-onboarding-app-stack/stack-orchestrator/stacks/onboarding-api
Prathamesh Musale 1e3e592b10 Add stacks for testnet-onboarding-app and testnet-onboarding-api (#1)
Part of  [laconicd testnet validator enrollment](https://www.notion.so/laconicd-testnet-validator-enrollment-6fc1d3cafcc64fef8c5ed3affa27c675) and [Sumsub KYC integration in onboarding app](https://www.notion.so/Sumsub-KYC-integration-in-onboarding-app-607b598c9c1d4d12adc71725e2ab5e7e)

Reviewed-on: #1
Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
2024-07-26 06:31:40 +00:00
..
README.md Add stacks for testnet-onboarding-app and testnet-onboarding-api (#1) 2024-07-26 06:31:40 +00:00
stack.yml Add stacks for testnet-onboarding-app and testnet-onboarding-api (#1) 2024-07-26 06:31:40 +00:00

onboarding-api

Instructions for running the testnet-onboarding-api using laconic-so

Setup

  • Clone the stack repo:

    laconic-so fetch-stack git.vdb.to/cerc-io/testnet-onboarding-app-stack
    
  • Setup required repositories:

    laconic-so --stack ~/cerc/testnet-onboarding-app-stack/stack-orchestrator/stacks/onboarding-api setup-repositories
    
  • Build the container image:

    laconic-so --stack ~/cerc/testnet-onboarding-app-stack/stack-orchestrator/stacks/onboarding-api build-containers
    

    This should create the cerc/testnet-onboarding-api image locally

Create a deployment

  • Create a spec file for the deployment:

    laconic-so --stack ~/cerc/testnet-onboarding-app-stack/stack-orchestrator/stacks/onboarding-api deploy init --output onboarding-api-spec.yml
    
  • Edit network in the spec file to map container ports to host ports as required:

    network:
      ports:
        testnet-onboarding-api:
          - '3000:3000'
    
  • Create a deployment from the spec file:

    laconic-so --stack ~/cerc/testnet-onboarding-app-stack/stack-orchestrator/stacks/onboarding-api deploy create --spec-file onboarding-api-spec.yml --deployment-dir onboarding-api-deployment
    

Configuration

  • Inside the onboarding-api-deployment deployment directory, open config.env file and set following env variables:

    # Your sumsub application token
    SUMSUB_APP_TOKEN=
    
    # Your sumsub secret key
    SUMSUB_SECRET_KEY=
    
    # Optional
    
    # KYC level of access token being generated (default: basic-kyc-level)
    KYC_LEVEL=
    
    # TTL for the generated access token in seconds (default: 600)
    TTL_IN_SECS=
    

Start the deployment

laconic-so deployment --dir onboarding-api-deployment start

Check status

  • To list down and monitor the running container:

    # With status
    docker ps
    
    # Check logs for the server
    laconic-so deployment --dir onboarding-api-deployment logs -f testnet-onboarding-api
    

Run

  • Generate an access token for a user:

    curl -X POST http://localhost:3000/generate-token \
      -H "Content-Type: application/json" \
      -d '{"userId": "JamesBond007"}'
    
    # Expected output:
    # {"token":"generated-access-token"}
    

Clean up

  • Stop the deployment:

    laconic-so deployment --dir onboarding-api-deployment stop