Comparing version 2.0.2 to 2.1.0
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -8,0 +9,0 @@ }); |
import { ApiInterface, ExegesisRunner, ResponseValidationCallback, ExegesisOptions } from '../types'; | ||
import PluginsManager from './PluginsManager'; | ||
import { handleErrorFunction } from "../types/options"; | ||
import { HandleErrorFunction } from "../types/options"; | ||
/** | ||
@@ -12,3 +12,3 @@ * Returns a `(req, res) => Promise<boolean>` function, which handles incoming | ||
export default function generateExegesisRunner<T>(api: ApiInterface<T>, options: { | ||
autoHandleHttpErrors: boolean | handleErrorFunction; | ||
autoHandleHttpErrors: boolean | HandleErrorFunction; | ||
plugins: PluginsManager; | ||
@@ -15,0 +15,0 @@ onResponseValidationError: ResponseValidationCallback; |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -187,3 +188,3 @@ }); | ||
if (options.autoHandleHttpErrors instanceof Function) { | ||
return options.autoHandleHttpErrors(err); | ||
return options.autoHandleHttpErrors(err, { req }); | ||
} | ||
@@ -190,0 +191,0 @@ return handleError(err); |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -8,0 +9,0 @@ }); |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -8,0 +9,0 @@ }); |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -8,0 +9,0 @@ }); |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -8,0 +9,0 @@ }); |
import { MimeTypeRegistry } from './utils/mime'; | ||
import { CustomFormats, ExegesisOptions, StringParser, BodyParser, Controllers, Authenticators, ResponseValidationCallback } from './types'; | ||
import { handleErrorFunction } from './types/options'; | ||
import { HandleErrorFunction } from './types/options'; | ||
export interface ExegesisCompiledOptions { | ||
@@ -13,3 +13,3 @@ customFormats: CustomFormats; | ||
allowMissingControllers: boolean; | ||
autoHandleHttpErrors: boolean | handleErrorFunction; | ||
autoHandleHttpErrors: boolean | HandleErrorFunction; | ||
onResponseValidationError: ResponseValidationCallback; | ||
@@ -16,0 +16,0 @@ validateDefaultResponses: boolean; |
@@ -12,16 +12,24 @@ "use strict"; | ||
const loadControllers_1 = require("./controllers/loadControllers"); | ||
const INT_32_MAX = Math.pow(2, 32) - 1; | ||
// Actually 18446744073709551616-1, but Javascript doesn't handle integers this large. | ||
const INT_64_MAX = 18446744073709556000; | ||
const INT_32_MIN = -1 * Math.pow(2, 31); | ||
const INT_32_MAX = Math.pow(2, 31) - 1; | ||
// Javascript can only safely support a range of -(2^53 - 1) to (2^53 - 1) | ||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER | ||
const INT_64_MIN = Number.MIN_SAFE_INTEGER; | ||
const INT_64_MAX = Number.MAX_SAFE_INTEGER; | ||
// See the OAS 3.0 specification for full details about supported formats: | ||
// https://github.com/OAI/OpenAPI-Specification/blob/3.0.2/versions/3.0.2.md#data-types | ||
const defaultValidators = { | ||
// string:date is taken care of for us: | ||
// https://github.com/epoberezkin/ajv/blob/797dfc8c2b0f51aaa405342916cccb5962dd5f21/lib/compile/formats.js#L34 | ||
// string:date-time is from https://tools.ietf.org/html/draft-wright-json-schema-validation-00#section-7.3.1. | ||
// https://github.com/epoberezkin/ajv/blob/797dfc8c2b0f51aaa405342916cccb5962dd5f21/lib/compile/formats.js#L34 | ||
// string:date-time is from: | ||
// https://tools.ietf.org/html/draft-wright-json-schema-validation-00#section-7.3.1. | ||
// number:int32 and number:int64 are defined as non-fractional integers | ||
// https://tools.ietf.org/html/draft-wright-json-schema-00#section-5.3 | ||
int32: { | ||
type: 'number', | ||
validate: (value) => value >= 0 && value <= INT_32_MAX, | ||
validate: (value) => value >= INT_32_MIN && value <= INT_32_MAX | ||
}, | ||
int64: { | ||
type: 'number', | ||
validate: (value) => value >= 0 && value <= INT_64_MAX, | ||
validate: (value) => value >= INT_64_MIN && value <= INT_64_MAX | ||
}, | ||
@@ -28,0 +36,0 @@ double: { |
@@ -0,4 +1,6 @@ | ||
/// <reference types="node" /> | ||
import { StringParser, BodyParser } from './bodyParser'; | ||
import { Controllers, Authenticators, ExegesisPlugin } from './core'; | ||
import { ResponseValidationCallback } from './validation'; | ||
import * as http from "http"; | ||
/** | ||
@@ -8,3 +10,5 @@ * A function which validates custom formats. | ||
export declare type CustomFormatChecker = RegExp | ((value: string) => boolean); | ||
export declare type handleErrorFunction = (err: Error) => any; | ||
export declare type HandleErrorFunction = (err: Error, context: { | ||
req: http.IncomingMessage; | ||
}) => any; | ||
export interface StringCustomFormatChecker { | ||
@@ -100,3 +104,3 @@ type: 'string'; | ||
*/ | ||
autoHandleHttpErrors?: boolean | handleErrorFunction; | ||
autoHandleHttpErrors?: boolean | HandleErrorFunction; | ||
/** | ||
@@ -103,0 +107,0 @@ * If you provide this function, Exegesis will validate responses controllers |
{ | ||
"name": "exegesis", | ||
"version": "2.0.2", | ||
"version": "2.1.0", | ||
"description": "Parses OpenAPI documents", | ||
@@ -66,5 +66,5 @@ "main": "lib/index.js", | ||
"coveralls": "^3.0.2", | ||
"husky": "^2.0.0", | ||
"lint-staged": "^8.1.4", | ||
"markdownlint-cli": "^0.16.0", | ||
"husky": "^3.0.0", | ||
"lint-staged": "^9.2.4", | ||
"markdownlint-cli": "^0.18.0", | ||
"mocha": "^6.1.4", | ||
@@ -71,0 +71,0 @@ "nyc": "^14.0.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
297554
4576