New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

openapi-connect

Package Overview
Dependencies
Maintainers
0
Versions
105
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openapi-connect

Base for microservices around OpenAPI/Swagger

  • 2.6.1
  • latest
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

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(), // instance of logger implemented contract from loggerism package
  router: {
    controllers: './bin/controllers' // path to folder where we request handlers can be found or object like { [operationName: string]: RequestHandler }
  },
  // in case OpenID/OAuth required
  oauth: {
    enable: true,
    url: env.OAUTH_SERVICE_URL,
    audience: env.OAUTH_AUDIENCE // optional
  },
  swaggerUI: { enable: env.ENABLE_SWAGGER_UI } // optional
}

server('./api/public.yaml', options)

TODO

  • Use semantic-release
  • Add monitoring/instrumentation with OpenTracing compatibility like @risingstack/opentracing-auto or appmetrics
  • Move to GitHub and use Travis CI for better opportunity to force open source.

Keywords

FAQs

Package last updated on 04 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc