Gathering detailed insights and metrics for exegesis
Gathering detailed insights and metrics for exegesis
Gathering detailed insights and metrics for exegesis
Gathering detailed insights and metrics for exegesis
npm install exegesis
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
139 Stars
437 Commits
36 Forks
9 Watching
59 Branches
16 Contributors
Updated on 28 Aug 2024
TypeScript (99.56%)
JavaScript (0.44%)
Cumulative downloads
Total Downloads
Last day
-0.6%
89,719
Compared to previous day
Last week
2.6%
477,224
Compared to previous week
Last month
9.7%
2,018,437
Compared to previous month
Last year
10.6%
21,519,478
Compared to previous year
17
29
exegesis
n. An explanation or critical interpretation of a text, especially an API definition document.
-- No dictionary ever
This library implements a framework-agnostic server side implementation of OpenAPI 3.x.
Exegesis is a library for implementing server-side OpenAPI 3.x The library has been written in such a way that hopefully it will also be used to implement future versions of OpenAPI, or possibly even other API description standards altogether.
You probably don't want to be using this library directly. Have a look at:
Check out the tutorial here.
This function takes an API document and a set of options, and returns a connect-style middleware function which will execute the API.
openApiDoc
is either a path to your openapi.yaml or openapi.json file,
or it can be a JSON object with the contents of your OpenAPI document. This
should have the x-exegesis-controller
extension defined on any paths you want to be able to access.
options
is described in detail here. At a
minimum, you'll probably want to provide options.controllers
, a path to where
your controller modules
can be found. If you have any security requirements defined, you'll also
want to pass in some authenticators.
To enable response validation, you'll want to provide a validation callback
function via onResponseValidationError()
.
Exegesis's functionality can also be extended using plugins,
which run on every request. Plugins let you add functionality like
role base authorization,
or CORS.
This function is similar to compileApi
; it takes an API document and a set of
options,
and returns a "runner". The runner is a function runner(req, res)
, which takes
in a standard node HTTP request and response. It will not modify the response,
however. Instead it returns (either via callback or Promise) and HttpResult
object. This is a {headers, status, body}
object, where body
is a readable
stream, read to be piped to the response.
A convenience function for writing an HttpResult
from a runner out to the
response.
1import * as path from 'path'; 2import * as http from 'http'; 3import * as exegesis from 'exegesis'; 4 5// See https://github.com/exegesis-js/exegesis/blob/master/docs/Options.md 6const options = { 7 controllers: path.resolve(__dirname, './src/controllers'), 8}; 9 10// `compileApi()` can either be used with a callback, or if none is provided, 11// will return a Promise. 12exegesis.compileApi( 13 path.resolve(__dirname, './openapi/openapi.yaml'), 14 options, 15 (err, middleware) => { 16 if (err) { 17 console.error('Error creating middleware', err.stack); 18 process.exit(1); 19 } 20 21 const server = http.createServer((req, res) => 22 middleware(req, res, (err) => { 23 if (err) { 24 res.writeHead(err.status || 500); 25 res.end(`Internal error: ${err.message}`); 26 } else { 27 res.writeHead(404); 28 res.end(); 29 } 30 }) 31 ); 32 33 server.listen(3000); 34 } 35);
Internally, when you "compile" an API, Exegesis produces an
ApiInterface object.
This is an object that, given a method, url, and headers, returns a
resolvedOperation
-
essentially a collection of functions that will parse and validate the body and
parameters, has the controller that executes the functionality, etc... The only
current implementation for an ApiInterface is the
oas3/OpenApi
class.
Essentially this class's job is to take in an OpenAPI 3.x.x document, and turn it
an ApiInterface that Exegesis can use. In theory, however, we could parse some
other API document format, produce an ApiInterface, and Exegsis would still be
able to run it.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 4/12 approved changesets -- score normalized to 3
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
22 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More