Socket
Socket
Sign inDemoInstall

exegesis

Package Overview
Dependencies
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

exegesis

Parses OpenAPI documents


Version published
Weekly downloads
365K
decreased by-21.16%
Maintainers
1
Weekly downloads
 
Created

What is exegesis?

Exegesis is a library for building REST APIs using OpenAPI (formerly known as Swagger). It allows you to define your API using an OpenAPI specification and then automatically handles request validation, response validation, and routing based on that specification.

What are exegesis's main functionalities?

Request Validation

This code demonstrates how to set up request validation using Exegesis. It uses an OpenAPI specification file to automatically validate incoming requests against the defined API schema.

const exegesisExpress = require('exegesis-express');
const express = require('express');
const path = require('path');

const app = express();

const options = {
  controllers: path.resolve(__dirname, './controllers'),
};

exegesisExpress.middleware(path.resolve(__dirname, './openapi.yaml'), options)
  .then((middleware) => {
    app.use(middleware);
    app.listen(3000, () => {
      console.log('Listening on port 3000');
    });
  });

Response Validation

This code demonstrates how to set up response validation using Exegesis. It ensures that the responses sent by the server conform to the OpenAPI specification.

const exegesisExpress = require('exegesis-express');
const express = require('express');
const path = require('path');

const app = express();

const options = {
  controllers: path.resolve(__dirname, './controllers'),
};

exegesisExpress.middleware(path.resolve(__dirname, './openapi.yaml'), options)
  .then((middleware) => {
    app.use(middleware);
    app.use((req, res, next) => {
      res.json({ message: 'Hello, world!' });
    });
    app.listen(3000, () => {
      console.log('Listening on port 3000');
    });
  });

Routing

This code demonstrates how to set up routing using Exegesis. It automatically routes incoming requests to the appropriate controller based on the OpenAPI specification.

const exegesisExpress = require('exegesis-express');
const express = require('express');
const path = require('path');

const app = express();

const options = {
  controllers: path.resolve(__dirname, './controllers'),
};

exegesisExpress.middleware(path.resolve(__dirname, './openapi.yaml'), options)
  .then((middleware) => {
    app.use(middleware);
    app.listen(3000, () => {
      console.log('Listening on port 3000');
    });
  });

Other packages similar to exegesis

Keywords

FAQs

Package last updated on 11 Mar 2020

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