The "Jolocom Backend Challenge" is a reference application using jolocoms current pattern for an API backend with typescript.
The application uses an "API First" approach, where the api contract is defined as an "OpenAPI 3.0" specification located in 'openapi.yaml'.
There exist a few tools / conveniences included in this application to aid in this:
yarn generate-schemas
(oryarn build
) can be used to generate typescript interfaces for the schemas defined in the open api spec. They will be placed insrc/api/generated-schemas/models
.- Middleware is included to automatically validate incoming requests (and also responses) against the open api specification.
- The spec can be wired up to class based controllers by using
x-swagger-router-controller
to specify the name of a controller class, andoperationId
to specify a method that will handle the operation/endpoint. - The
AppRequest
andResponse
types can be used in controller methods to correctly type the requests and responses.
- node14 & yarn
To build your application on top of "Jolocom Backend Challenge Service" you need just follow 5 simple steps:
- Fork it (rename if required).
- Clone forked repository.
- Install dependencies.
- Configure application.
- Run it.
Yarn:
yarn
First of all you need to create .env
file with required environment variables
(.env.dist
is an example of .env
).
For simplification of creation default .env
file, was added command under the "scripts" definition:
Yarn:
yarn run dotenv-init
Yarn:
yarn run start
Or run in debug mode (after run in debug mode you can attach debugger):
Yarn:
yarn run debug
🎉 At this point you have configured a working application with an example endpoint.
To see list of all available endpoints you can use 'Swagger UI' (sandbox) which can be reached on http://localhost:9000/docs (with default server configuration).
There are a few useful yarn commands for development.
yarn start
- Run the application with hot reloads
yarn debug
- Run in debug mode so a debugger can be attached
yarn generate-schemas
- Generate typescript interfaces from openapi schemas
yarn format
- Format with prettier
yarn lint
- Lint with eslint
yarn test
- Run tests with jest