Socket
Socket
Sign inDemoInstall

@mocks-server/core

Package Overview
Dependencies
12
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.1.0

11

CHANGELOG.md

@@ -8,5 +8,4 @@ # Change Log

## [To be deprecated]
- Deprecate options "features" and "feature".
- Deprecate options "features", "behaviors" and "feature".
- Remove "features" getter from Server
- Remove Server and Cli constructors. Use @mocks-server/core instead

@@ -19,2 +18,10 @@ ## [unreleased]

## [1.1.0] - 2019-12-07
### Changed
- "behaviors" option renamed to "path". Old option still working due to backward compatibility.
- "path" option has "mocks" value by default. The server will create path if it does not exist.
### Fixed
- Fix server started log. Was always printing localhost, without taking into account custom "host" option.
## [1.0.0] - 2019-11-29

@@ -21,0 +28,0 @@ ### Added

4

package.json
{
"name": "@mocks-server/core",
"version": "1.0.0",
"version": "1.1.0",
"description": "Pluggable mocks server supporting multiple api behaviors",

@@ -48,2 +48,3 @@ "keywords": [

"express-request-id": "1.4.1",
"fs-extra": "^8.1.0",
"lodash": "4.17.15",

@@ -60,3 +61,2 @@ "node-watch": "0.6.3",

"eslint-plugin-prettier": "^3.1.1",
"fs-extra": "^8.1.0",
"husky": "3.0.9",

@@ -63,0 +63,0 @@ "is-promise": "^2.1.0",

@@ -20,3 +20,3 @@ [![Build status][travisci-image]][travisci-url] [![Coverage Status][coveralls-image]][coveralls-url] [![Quality Gate][quality-gate-image]][quality-gate-url]

* [Tutorials](https://www.mocks-server.org/docs/tutorials-static)
* [Configuration](https://www.mocks-server.org/docs/configuration-command-line-arguments)
* [Configuration](https://www.mocks-server.org/docs/configuration-options)

@@ -23,0 +23,0 @@ ## Contributing

@@ -16,2 +16,3 @@ /*

const watch = require("node-watch");
const fsExtra = require("fs-extra");

@@ -73,5 +74,3 @@ const { map, debounce } = require("lodash");

if (!folder) {
tracer.error(
'Please provide a path to a folder containing behaviors using the "behaviors" option'
);
tracer.error('Please provide a path to the folder containing mocks using the "path" option');
throw Boom.badData("Invalid mocks folder");

@@ -85,4 +84,9 @@ }

_ensureFolder(folder) {
fsExtra.ensureDirSync(folder);
return folder;
}
_loadFiles() {
this._path = this._resolveFolder(this._settings.get("behaviors"));
this._path = this._ensureFolder(this._resolveFolder(this._settings.get("path")));
tracer.info(`Loading mocks from folder ${this._path}`);

@@ -116,3 +120,3 @@ this._cleanRequireCacheFolder();

_onChangeSettings(changeDetails) {
if (changeDetails.hasOwnProperty("behaviors")) {
if (changeDetails.hasOwnProperty("path")) {
this._loadFiles();

@@ -119,0 +123,0 @@ this._switchWatch();

@@ -82,7 +82,11 @@ /*

_startServer(resolve, reject) {
const host = this._settings.get("host");
const port = this._settings.get("port");
const hostName = host === "0.0.0.0" ? "localhost" : host;
try {
this._server.listen(
{
port: this._settings.get("port"),
host: this._settings.get("host")
port,
host
},

@@ -97,5 +101,3 @@ error => {

} else {
tracer.info(
`Server started and listening at http://localhost:${this._settings.get("port")}`
);
tracer.info(`Server started and listening at http://${hostName}:${port}`);
this._error = null;

@@ -102,0 +104,0 @@ this._serverStarting = false;

@@ -24,4 +24,4 @@ /*

this._commander = commander
.option("--path <path>", "Define folder from which load mocks")
.option("--behavior <behavior>", "Define current behavior")
.option("--behaviors <behaviors>", "Define folder from which load behaviors")
.option("--delay <delay>", "Define delay time")

@@ -34,3 +34,4 @@ .option("--host <host>", "Host for server")

.option("--feature <feature>", "Define current behavior")
.option("--features <features>", "Define folder from which load behaviors");
.option("--features <features>", "Define folder from which load mocks")
.option("--behaviors <behaviors>", "Define folder from which load mocks");
}

@@ -37,0 +38,0 @@

@@ -20,3 +20,3 @@ /*

behavior: null,
behaviors: null,
path: "mocks",
delay: 0,

@@ -29,3 +29,4 @@ host: "0.0.0.0",

feature: null,
features: null
features: null,
behaviors: null
};

@@ -35,3 +36,4 @@

feature: "behavior",
features: "behaviors"
behaviors: "path",
features: "path"
};

@@ -138,3 +140,3 @@

const newOption = DEPRECATED_OPTIONS[optionName];
if (!options[newOption]) {
if (options[newOption] === DEFAULT_OPTIONS[newOption]) {
options[newOption] = options[optionName];

@@ -141,0 +143,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc