@logion/rest-api-core
TypeScript icon, indicating that this package has built-in type declarations

0.5.0 • Public • Published

logion-rest-api-core

This library provides the core functionlities that all logion REST-based off-chain services have in common:

  • The Authentication controller exposing the REST resources for authentication
  • A service maintaining a singleton connection to a logion node
  • OpenAPI helpers
  • TypeORM helpers
  • Dinoloop helpers
  • Inversify helpers
  • Test helpers
  • Various utilities

Usage

Configuring OpenAPI

Below call adds the authentication-related elements to an OpenAPI V3 document.

const spec: OpenAPIV3.Document = ...;
configureOpenApi(spec);

Configure Dinoloop

Below call registers the authentication controller as well as the default application error controller and a JSON response middleware.

const dino: Dino = ...;
configureDinoloop(dino);

Configure Inversify

Below call binds all provided services in the container.

const container: Container = ...;
configureContainer(container);

TypeORM

Simply import the app's data source:

import { appDataSource } from "@logion/rest-api-core";

The returned data source is configured using ormconfig.json file and TYPEORM_* environment variables. This is essentially a re-implementation of the way TypeORM used to be configured before the introduction of the multiple data source feature.

The returned data source is ready to be used with a transaction context. DefaultTransactional method decorator can be used to set a transaction context with default settings. typeorm-transactional's Transactional decorator may also be used safely.

Readme

Keywords

Package Sidebar

Install

npm i @logion/rest-api-core

Weekly Downloads

66

Version

0.5.0

License

Apache-2.0

Unpacked Size

74.7 kB

Total Files

46

Last publish

Collaborators

  • benoitdevos
  • gdethier