Base for microservices around OpenAPI/Swagger
- Use Swagger 2.0 (OpenAPI in feature) specification as source of trues about all aspects of service like security/validation/routing/etc (thanks swagger-tools)
- Support OpenID/OAuth
- Support request logging
- Base implementation for service health checking
- Base graceful shutdown implementation
Almost all middleware like (OAuth/CORS/request logging/etc) can be overridden through options.
Steps to use
- According to API first approach write OpenAPI/Swagger specification for your service and save it to something like
./api/public.yaml
npm i openapi-connect
to install- Write
intex.ts
or index.js
as
import server, { IOptions } from 'openapi-connect'
const options: IOptions = {
basePath: env.BASE_PATH,
port: env.PORT,
logger: getLogger(),
router: {
controllers: './bin/controllers'
},
oauth: {
enable: true,
url: env.OAUTH_SERVICE_URL,
audience: env.OAUTH_AUDIENCE
},
swaggerUI: { enable: env.ENABLE_SWAGGER_UI }
}
server('./api/public.yaml', options)
TODO