blackbox-root-service
v1.0.0
Published
Provides services for a Blackbox API root and parent services with sub-services.
Downloads
1
Readme
blackbox-root-service
Automatically creates services for the Blackbox API root and any parent services.
Through the init()
function, services are automatically created for the Blackbox API root and any parent services. The services are added to the Blackbox IOC container for use by a Blackbox server (typically generated via the Blackbox CLI).
For further information about the Blackbox Specification refer to the Blackbox website.
Table of Contents
Install
npm i blackbox-root-service
Usage
Generate service handlers for all parent services:
import init from "blackbox-root-service"
init()
The generated service handlers will be tagged as services in the Blackbox IOC container. They can then be accessed from server to provide the response for a request to the parent service API.
The generated services rely on the OpenAPI document, an instance of which must be provided to the IOC container and named 'oasDoc', for example:
@factory('oasDoc')
loadOasDoc() {
const oasDocData:any = fs.readFileSync(path.join(__dirname,'openapi.json'))
return JSON.parse(oasDocData.toString())
}
Generally the above two steps will be all you will want to do - for example, the OpenAPI document is named via a factory and init()
is called from index.ts in a Blackbox server generated with the Blackbox CLI. However, sometimes you may wish to access the root service or a child service. This is easily done through autowiring:
class MyClass {
@autowiredService('root-service')
rootService:any
@autowiredService('my-service')
myService:any
}
Maintainers
Contributing
PRs accepted.
Small note: If editing the README, please conform to the standard-readme specification.
License
MIT © 2019 Ben Millar