exegesis-express
Advanced tools
Comparing version 3.0.0 to 4.0.0
{ | ||
"name": "exegesis-express", | ||
"version": "3.0.0", | ||
"version": "4.0.0", | ||
"description": "Express middleware to handle OpenAPI 3.x.", | ||
@@ -53,3 +53,3 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"exegesis": "^3.0.0" | ||
"exegesis": "^4.1.0" | ||
}, | ||
@@ -60,4 +60,4 @@ "devDependencies": { | ||
"@types/express": "^4.16.1", | ||
"@types/mocha": "^8.2.2", | ||
"@types/node": "^15.0.3", | ||
"@types/mocha": "^9.0.0", | ||
"@types/node": "^16.11.12", | ||
"chai": "^4.2.0", | ||
@@ -67,9 +67,10 @@ "chai-as-promised": "^7.1.1", | ||
"express": "^4.16.4", | ||
"husky": "^6.0.0", | ||
"lint-staged": "^11.0.0", | ||
"mocha": "^8.4.0", | ||
"husky": "^7.0.4", | ||
"lint-staged": "^12.1.2", | ||
"mocha": "^9.1.3", | ||
"nyc": "^15.0.1", | ||
"semantic-release": "^17.4.3", | ||
"pretty-quick": "^3.1.2", | ||
"semantic-release": "^18.0.1", | ||
"supertest-fetch": "^1.2.4", | ||
"ts-node": "^9.1.1", | ||
"ts-node": "^10.4.0", | ||
"tslint": "^6.1.3", | ||
@@ -76,0 +77,0 @@ "typescript": "^4.2.4" |
# exegesis-express | ||
[![NPM version](https://badge.fury.io/js/exegesis-express.svg)](https://npmjs.org/package/exegesis-express) | ||
[![Build Status](https://travis-ci.org/exegesis-js/exegesis-express.svg)](https://travis-ci.org/exegesis-js/exegesis-express) | ||
![Build Status](https://github.com/exegesis-js/exegesis-express/workflows/GitHub%20CI/badge.svg) | ||
[![Coverage Status](https://coveralls.io/repos/exegesis-js/exegesis-express/badge.svg)](https://coveralls.io/r/exegesis-js/exegesis-express) | ||
@@ -9,5 +9,5 @@ [![Greenkeeper badge](https://badges.greenkeeper.io/exegesis-js/exegesis-express.svg)](https://greenkeeper.io/) | ||
> ## *exegesis* | ||
> ## _exegesis_ | ||
> | ||
> *n.* An explanation or critical interpretation of a text, especially an | ||
> _n._ An explanation or critical interpretation of a text, especially an | ||
> API definition document. | ||
@@ -22,9 +22,9 @@ > | ||
* Full support for OpenAPI 3.x.x (see [issues tagged with conformance](https://github.com/exegesis-js/exegesis/issues?q=is%3Aissue+is%3Aopen+label%3Aconformance) for areas which could use some improvement). | ||
* Built in support for "application/json" and "application/x-www-form-urlencoded" requests | ||
* Can use express [body parser middlewares](https://github.com/exegesis-js/exegesis/blob/master/docs/Options.md#mimetypeparsers) | ||
* [Response validation](https://github.com/exegesis-js/exegesis/blob/master/docs/Options.md#onresponsevalidationerror) | ||
* [Authentication support](https://github.com/exegesis-js/exegesis/blob/master/docs/OAS3%20Security.md) | ||
* [Plugins](https://github.com/exegesis-js/exegesis/tree/master/docs) allow easy extensibility | ||
* Easy support for [validating custom formats](https://github.com/exegesis-js/exegesis/blob/master/docs/Options.md#customformats) | ||
- Full support for OpenAPI 3.x.x (see [issues tagged with conformance](https://github.com/exegesis-js/exegesis/issues?q=is%3Aissue+is%3Aopen+label%3Aconformance) for areas which could use some improvement). | ||
- Built in support for "application/json" and "application/x-www-form-urlencoded" requests | ||
- Can use express [body parser middlewares](https://github.com/exegesis-js/exegesis/blob/master/docs/Options.md#mimetypeparsers) | ||
- [Response validation](https://github.com/exegesis-js/exegesis/blob/master/docs/Options.md#onresponsevalidationerror) | ||
- [Authentication support](https://github.com/exegesis-js/exegesis/blob/master/docs/OAS3%20Security.md) | ||
- [Plugins](https://github.com/exegesis-js/exegesis/tree/master/docs) allow easy extensibility | ||
- Easy support for [validating custom formats](https://github.com/exegesis-js/exegesis/blob/master/docs/Options.md#customformats) | ||
@@ -43,10 +43,10 @@ ## Tutorial | ||
`openApiFile` 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 | ||
or it can be a JSON object with the contents of your OpenAPI document. This | ||
should have the [`x-exegesis-controller`](https://github.com/exegesis-js/exegesis/blob/master/docs/OAS3%20Specification%20Extensions.md) | ||
extension defined on any paths you want to be able to access. | ||
`options` can be [anything you can pass to exegesis](https://github.com/exegesis-js/exegesis/blob/master/docs/Options.md). At a | ||
`options` can be [anything you can pass to exegesis](https://github.com/exegesis-js/exegesis/blob/master/docs/Options.md). At a | ||
minimum, you'll probably want to provide `options.controllers`, a path to where | ||
your [controller modules](https://github.com/exegesis-js/exegesis/blob/master/docs/Exegesis%20Controllers.md) | ||
can be found. If you have any security requirements defined, you'll also | ||
can be found. If you have any security requirements defined, you'll also | ||
want to pass in some [authenticators](https://github.com/exegesis-js/exegesis/blob/master/docs/OAS3%20Security.md). | ||
@@ -56,3 +56,3 @@ To enable response validation, you'll want to provide a validation callback | ||
Exegesis's functionality can also be extended using [plugins](https://github.com/exegesis-js/exegesis/tree/master/docs), | ||
which run on every request. Plugins let you add functionality like | ||
which run on every request. Plugins let you add functionality like | ||
[role base authorization](https://github.com/exegesis-js/exegesis-plugin-roles), | ||
@@ -64,4 +64,4 @@ or CORS. | ||
Exegesis-express should appear near the top of your middleware stack, before | ||
any body parsers. This is because exegesis will take care of parsing the body | ||
for you, and it can't do that if the body has already been read. If you put | ||
any body parsers. This is because exegesis will take care of parsing the body | ||
for you, and it can't do that if the body has already been read. If you put | ||
a body parser ahead of exegesis-express, exegesis will try to use `req.body` | ||
@@ -72,7 +72,7 @@ if it's there. | ||
OpenAPI 3.x lets you specify what servers your API is available on. For example: | ||
OpenAPI 3.x lets you specify what servers your API is available on. For example: | ||
```yaml | ||
servers: | ||
- url: '/api/v2' | ||
- url: "/api/v2" | ||
``` | ||
@@ -89,11 +89,11 @@ | ||
If you specify the `ignoreServers` option, however, exegesis will ignore the | ||
servers section, an route purely based on your paths. This lets you do | ||
servers section, an route purely based on your paths. This lets you do | ||
something like: | ||
```js | ||
const exegesisMiddleware = await exegesisExpress.middleware( | ||
path.resolve(__dirname, './openapi.yaml'), | ||
{ignorePaths: true} | ||
); | ||
app.use('/api/v2', exegesisMiddleware); | ||
const exegesisMiddleware = await exegesisExpress.middleware( | ||
path.resolve(__dirname, "./openapi.yaml"), | ||
{ ignorePaths: true } | ||
); | ||
app.use("/api/v2", exegesisMiddleware); | ||
``` | ||
@@ -106,33 +106,33 @@ | ||
```js | ||
import express from 'express'; | ||
import path from 'path'; | ||
import http from 'http'; | ||
import * as exegesisExpress from 'exegesis-express'; | ||
import express from "express"; | ||
import path from "path"; | ||
import http from "http"; | ||
import * as exegesisExpress from "exegesis-express"; | ||
async function createServer() { | ||
// See https://github.com/exegesis-js/exegesis/blob/master/docs/Options.md | ||
const options = { | ||
controllers: path.resolve(__dirname, './controllers') | ||
}; | ||
// See https://github.com/exegesis-js/exegesis/blob/master/docs/Options.md | ||
const options = { | ||
controllers: path.resolve(__dirname, "./controllers"), | ||
}; | ||
const exegesisMiddleware = await exegesisExpress.middleware( | ||
path.resolve(__dirname, './openapi.yaml'), | ||
options | ||
); | ||
const exegesisMiddleware = await exegesisExpress.middleware( | ||
path.resolve(__dirname, "./openapi.yaml"), | ||
options | ||
); | ||
const app = express(); | ||
const app = express(); | ||
// If you have any body parsers, this should go before them. | ||
app.use(exegesisMiddleware); | ||
// If you have any body parsers, this should go before them. | ||
app.use(exegesisMiddleware); | ||
app.use((req, res) => { | ||
res.status(404).json({message: `Not found`}); | ||
}); | ||
app.use((req, res) => { | ||
res.status(404).json({ message: `Not found` }); | ||
}); | ||
app.use((err, req, res, next) => { | ||
res.status(500).json({message: `Internal error: ${err.message}`}); | ||
}); | ||
app.use((err, req, res, next) => { | ||
res.status(500).json({ message: `Internal error: ${err.message}` }); | ||
}); | ||
const server = http.createServer(app); | ||
server.listen(3000); | ||
const server = http.createServer(app); | ||
server.listen(3000); | ||
} | ||
@@ -139,0 +139,0 @@ ``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12254
19
+ Added@isaacs/cliui@8.0.2(transitive)
+ Added@pkgjs/parseargs@0.11.0(transitive)
+ Addedansi-regex@5.0.16.1.0(transitive)
+ Addedansi-styles@4.3.06.2.1(transitive)
+ Addedbrace-expansion@2.0.1(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedcross-spawn@7.0.3(transitive)
+ Addedeastasianwidth@0.2.0(transitive)
+ Addedemoji-regex@8.0.09.2.2(transitive)
+ Addedexegesis@4.2.0(transitive)
+ Addedforeground-child@3.3.0(transitive)
+ Addedglob@10.4.5(transitive)
+ Addedis-fullwidth-code-point@3.0.0(transitive)
+ Addedisexe@2.0.0(transitive)
+ Addedjackspeak@3.4.3(transitive)
+ Addedjson-ptr@3.1.1(transitive)
+ Addedlru-cache@10.4.3(transitive)
+ Addedminimatch@9.0.5(transitive)
+ Addedminipass@7.1.2(transitive)
+ Addedopenapi3-ts@3.2.0(transitive)
+ Addedpackage-json-from-dist@1.0.0(transitive)
+ Addedpath-key@3.1.1(transitive)
+ Addedpath-scurry@1.11.1(transitive)
+ Addedpromise-breaker@6.0.0(transitive)
+ Addedshebang-command@2.0.0(transitive)
+ Addedshebang-regex@3.0.0(transitive)
+ Addedsignal-exit@4.1.0(transitive)
+ Addedstring-width@4.2.35.1.2(transitive)
+ Addedstrip-ansi@6.0.17.1.0(transitive)
+ Addedwhich@2.0.2(transitive)
+ Addedwrap-ansi@7.0.08.1.0(transitive)
+ Addedyaml@2.5.1(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removedexegesis@3.0.1(transitive)
- Removedfs.realpath@1.0.0(transitive)
- Removedglob@7.2.3(transitive)
- Removedinflight@1.0.6(transitive)
- Removedjson-ptr@2.2.0(transitive)
- Removedminimatch@3.1.2(transitive)
- Removedopenapi3-ts@2.0.2(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedpromise-breaker@5.0.0(transitive)
- Removedtslib@2.7.0(transitive)
- Removedyaml@1.10.2(transitive)
Updatedexegesis@^4.1.0