Skip to content

tf-govstack/bb-identity

 
 

Repository files navigation

ID Building Block

This building block is a reference implementation of the OpenAPI specification for the ID Building block.

Building and running the server

  1. Pull down a copy of this git repo and install node via npm and install packages, e.g. $ nvm install; yarn.

  2. Start the server in dev mode with $ yarn start:dev. Use yarn test to run tests. See package.json for other commands.

  3. To build a docker image, use $ docker-compose build.

  4. To release a new version, increment it in package.json and docker-compose.yml, then push the new version, e.g. $ docker push govstack/idbuildingblock:release-0.0.1.

Deploying the server

We are using Digital Ocean Apps to deploy docker images built locally and automatically via Docker Hub. To deploy a new version:

  1. Visit the DO app

  2. Select the Source tab

  3. Change the tag and click the 'Save' button. Use the latest tag to deploy the latest version automatically built off of the main branch by docker hub.

Operations

Dev notes

Time is of the essence, so I'll just use a generator and add a basic route manually for now...

$ npx express-generator-typescript --with-auth --socket-io --use-yarn "IDBuildingBlock"

I added the example API from swaggerhub to the generated server.

Generating from an openapi spec

Ideally, we can generate the server completely from OpenAPI. I'd like to use express and typescript, lots of folks know it.

https://blog.simonireilly.com/posts/typescript-openapi gives a good overview of the current situation with typescript server generation. The author is working on a [https://github.com/simonireilly/compeller](library called compeller) that looks promising. Unfortunately, it can't import OpenAPI just yet.

Trying openapi-generator (js only)

Use openapi-generator, based on Java. There isn't any support for typescript server generation.

I changed the version in verification.json to 3.0.0 then was able to generate this:

$ openapi-generator generate --skip-validate-spec  -g typescript-node -i ~/fabrik/BuildingBlockAPI/IDV/verification.json

Run Cucumber tests

Cucumber-js is used to execute test harness to check compability of application api with BB test definitions.

Mock server

Launch the mock server from examples/mock folder. The instruction is located in 'examples/mock' folder in file README.md

Cucumber tests

To install project's dependencies, navigate to folder 'test' and execute the following command:

yarn install

Then to execute all tests scenarios use the following command:

yarn test

or

npx cucumber-js

To execute specific test scenario use the following command:

npx cucumber-js features/<file_name>

example:

npx cucumber-js features/data_update_or_create.feature

About

The ID Building Block for GovStack

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 51.3%
  • Gherkin 27.3%
  • TypeScript 11.4%
  • HTML 7.8%
  • CSS 1.0%
  • Shell 0.8%
  • Dockerfile 0.4%