Options
All
  • Public
  • Public/Protected
  • All
Menu

lm-ts-api-poc-service

lm-ta-api-poc-service

POC service for API testing

Prerequisites

  1. NodeJS LTS (12+)
  2. Yarn

Install

yarn

Starting server

yarn start

Parameters

The following environment variables can be used to configure the service:

  • DISABLE_CRON to disable request processing CRON (default: false)
  • DEBUG_DB to enabled DB debugging (default: false)
  • PORT to set on which port the service should run (default: 3000)
  • MAX_FACTORY to set the maximum number of factories (ID) (default: 20000)
  • PROCESS_INTERVAL to set interval of request processing CRON (default: 5000 (ms))

Starting server in DEBUG mode

yarn start:debug

Debug mode is different than the normal mode in:

  1. Request processing CRON is DISABLED
  2. Database debugging is ENABLED (i.e. all response will contain the full DB)

API

Method URL Description Response
GET /lambda?factoryId Requests a new serial ID for the factory { token: "uuid" }
GET /service?requestToken Retrieves status of the request { status: "pending,provisioned,failed,timeout", id: "<if-provisioned-or-timedout>", "error": "<if-failed>" }

API for tests

Method URL Description Response
GET /process Trigger request processing {}
GET /clean Clean database {}
GET /factory?factoryId Returns the factory data { id: "1", last: "<last-sequence-n>", serials: ["<provisioned-sequence-ids>", ...], serialGaps: ["<gap-sequence-ids>"] }
GET /requests Returns all requests { requests: [ { factoryId: 123, status: "pending,provisioned,failed,timeout", token: "uuid", created: <ts>, _toBeFailed: false, _toBeGap: false }, ...]}

The /lambda accepts two parameters to handle negative and edge cases:

  • ?toBeGap - indicates that the generated serial ID should be considered as a gap and provisioned later
  • ?toBeFailed - indicates that the request processing should fail with Unknown error.

Docker

To build the image:

docker build -t lm-poc:latest .

Run service

docker run -d -p 3000:3000 lm-poc:latest

Run service in DEBUG mode

docker run -d -p 3000:3000 -e DISABLE_CRON=1 -e DEBUG_DB=1 lm-poc:latest

Docs

For detailed documentation see the TypeDocs documentation.

Generated using TypeDoc