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

mini-mock-api

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mini-mock-api - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

CHANGELOG.md

3

example/example.js

@@ -7,3 +7,4 @@ var API = require('../lib/mini-mock-api');

mockPath: 'mock-files',
idAttribute: '_id'
idAttribute: '_id',
cors: true
});

@@ -10,0 +11,0 @@

@@ -19,2 +19,3 @@ 'use strict';

idAttribute: 'uuid',
cors: false,
sortParameter: 'sortOrder'

@@ -24,2 +25,5 @@ };

this.app = express();
if(this.options.cors === true){
this.app.use(require('cors')());
}
return this;

@@ -46,3 +50,3 @@ };

console.log('Serving: ' + fileName);
response.json(this.decorate(responseData));
response.json(this.decorate(responseData, request));
}.bind(this),

@@ -69,3 +73,3 @@

console.log('Serving: ' + path.join(this.getFileName(splitted.path), splitted.id));
response.json(this.decorate(foundItem));
response.json(this.decorate(foundItem, request));
} else {

@@ -72,0 +76,0 @@ response.sendStatus(404);

{
"name": "mini-mock-api",
"version": "0.2.0",
"version": "0.2.1",
"description": "Lightweight node.js API mock server, route calls to static JSON files",

@@ -28,2 +28,3 @@ "main": "lib/mini-mock-api.js",

"dependencies": {
"cors": "^2.7.1",
"express": "^4.12.4",

@@ -30,0 +31,0 @@ "lodash-node": "^3.9.3",

@@ -68,2 +68,3 @@ # mini-mock-api

idAttribute: 'uuid', //the id property to search for when requesting api/v1/cars/123
cors: false, //CORS headers for cross origin requests
sortParameter: 'sortOrder' //the GET parameter for sort orders e.g. api/v1/cars?sortOrder=+name

@@ -95,6 +96,6 @@ }

All API responses can be decorated by defining a `decorate` function. In this example all returned collections are wrapped into `results` and a total count is added.
All API responses can be decorated by defining a `decorate` function. The functions also gets passed the request object as the second parameter. In this example all returned collections are wrapped into `results` and a total count is added.
```
myApi.decorate = function(data){
myApi.decorate = function(data, request){
if(data.length){

@@ -101,0 +102,0 @@ return {

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