Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

openapi-mock-express-middleware

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openapi-mock-express-middleware - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

12

CHANGELOG.md

@@ -5,2 +5,14 @@ # Changelog

## [1.3.0](https://github.com/aleksandryackovlev/openapi-mock-express-middleware/compare/v1.2.0...v1.3.0) (2020-08-31)
### Features
* **cors:** add preflight cors ([4fec346](https://github.com/aleksandryackovlev/openapi-mock-express-middleware/commit/4fec346660a48e372a7ca8f47ddf5adca4d98ad4))
### Bug Fixes
* **json-schema-faker:** change the order of extension functions in the generator ([a298234](https://github.com/aleksandryackovlev/openapi-mock-express-middleware/commit/a298234371ec0dec2728cb3ef51ded8bde3d7b03))
## [1.2.0](https://github.com/aleksandryackovlev/openapi-mock-express-middleware/compare/v1.1.0...v1.2.0) (2020-08-28)

@@ -7,0 +19,0 @@

4

dist/index.d.ts

@@ -8,5 +8,7 @@ import express from 'express';

options?: Partial<JSFOptions>;
cors?: CorsOptions;
cors?: CorsOptions & {
enabled?: boolean;
};
jsfCallback?: JSFCallback;
}
export declare const createMockMiddleware: ({ file, locale, options, cors, jsfCallback, }: MiddlewareOptions) => express.Router;

@@ -21,2 +21,3 @@ "use strict";

exports.createMockMiddleware = ({ file, locale = 'en', options = {}, cors = {
enabled: true,
origin: '*',

@@ -23,0 +24,0 @@ maxAge: 31536000,

import express from 'express';
import { CorsOptions } from 'cors';
declare const createRouter: (corsOptions: CorsOptions) => express.Router;
import cors, { CorsOptions } from 'cors';
declare const createRouter: ({ enabled, ...corsOptions }: cors.CorsOptions & {
enabled?: boolean | undefined;
}) => express.Router;
export default createRouter;
"use strict";
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -10,5 +21,9 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

const cors_1 = __importDefault(require("cors"));
const createRouter = (corsOptions) => {
const createRouter = (_a) => {
var { enabled } = _a, corsOptions = __rest(_a, ["enabled"]);
const router = express_1.default.Router();
router.use(cors_1.default(corsOptions));
if (enabled) {
router.options('*', cors_1.default(corsOptions));
router.use(cors_1.default(corsOptions));
}
router.use(express_1.default.urlencoded({ extended: true }));

@@ -15,0 +30,0 @@ router.use(express_1.default.json());

@@ -28,2 +28,3 @@ "use strict";

});
callback(json_schema_faker_1.default, faker_1.default);
json_schema_faker_1.default.define('example', (value) => {

@@ -33,3 +34,2 @@ return value;

json_schema_faker_1.default.define('examples', exports.handleExamples);
callback(json_schema_faker_1.default, faker_1.default);
return json_schema_faker_1.default;

@@ -36,0 +36,0 @@ };

{
"name": "openapi-mock-express-middleware",
"version": "1.2.0",
"version": "1.3.0",
"description": "Generates an express mock server from an Open API spec",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -63,2 +63,17 @@ <div align="center">

},
cors: { // cors options
enabled: true, // boolean, default to true
// default values are:
origin: '*',
enabled: true,
origin: '*',
maxAge: 31536000,
credentials: true,
methods: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS'],
allowedHeaders: ['Content-Type', 'Authorization', 'Origin', 'Accept'],
},
jsfCallback: (jsf, faker) => {
// function where you can extend json-schema-faker
...
}
}),

@@ -65,0 +80,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

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