Socket
Socket
Sign inDemoInstall

@mocks-server/plugin-admin-api

Package Overview
Dependencies
286
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.4.7 to 1.5.0

src/Alerts.js

12

CHANGELOG.md

@@ -17,2 +17,14 @@ # Change Log

## [1.5.0] - 2020-12-25
### Added
- feat(#78): Add alerts router
- chore(lint): Add eslint plugin to avoid only in tests
### Changed
- chore(deps): Update dependencies
- test(e2e): Move utils to a support folder
- feat: Add/remove routers on start/stop plugin methods, not in init method.
- style: Remove redundant `await` on a non-promise
## [1.4.7] - 2020-12-21

@@ -19,0 +31,0 @@

7

package.json
{
"name": "@mocks-server/plugin-admin-api",
"version": "1.4.7",
"version": "1.5.0",
"description": "Plugin for Mocks Server. Provides a REST API for administrating settings, fixtures and behaviors",

@@ -37,3 +37,3 @@ "keywords": [

"dependencies": {
"@mocks-server/admin-api-paths": "1.0.8",
"@mocks-server/admin-api-paths": "1.1.0",
"@hapi/boom": "9.1.0",

@@ -43,4 +43,5 @@ "express": "4.17.1"

"devDependencies": {
"@mocks-server/core": "1.5.1",
"@mocks-server/core": "1.6.0",
"eslint": "7.12.1",
"eslint-plugin-no-only-tests": "2.4.0",
"eslint-config-prettier": "6.15.0",

@@ -47,0 +48,0 @@ "eslint-plugin-prettier": "3.1.4",

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

FIXTURES,
ALERTS,
} = require("@mocks-server/admin-api-paths");

@@ -27,2 +28,3 @@

const Behaviors = require("./Behaviors");
const Alerts = require("./Alerts");
const Fixtures = require("./Fixtures");

@@ -46,2 +48,3 @@ const About = require("./About");

this._behaviorsApi = new Behaviors(this._core);
this._alertsApi = new Alerts(this._core);
this._aboutApi = new About(this._core);

@@ -70,6 +73,9 @@ this._fixturesApi = new Fixtures(this._core);

async init() {
await this._deprecatedApi.init();
this._core.onChangeSettings(this._onChangeSettings);
init() {
this._deprecatedApi.init();
this._initRouter();
}
start() {
this._stopListeningOnChangeSettings = this._core.onChangeSettings(this._onChangeSettings);
this._addDeprecatedRouter();

@@ -79,2 +85,10 @@ this._addRouter();

stop() {
if (this._stopListeningOnChangeSettings) {
this._stopListeningOnChangeSettings();
}
this._removeDeprecatedRouter();
this._removeRouter();
}
_initRouter() {

@@ -86,13 +100,8 @@ this._router = express.Router();

this._router.use(FIXTURES, this._fixturesApi.router);
this._router.use(ALERTS, this._alertsApi.router);
}
_addDeprecatedRouter() {
this._removeDeprecatedRouter();
if (
this._settings.get(ADMIN_API_DEPRECATED_PATHS_OPTION) === false &&
this._addedDeprecatedRouter
) {
this._core.removeRouter(DEPRECATED_API_PATH, this._deprecatedApi.router);
this._addedDeprecatedRouter = false;
}
if (
this._settings.get(ADMIN_API_DEPRECATED_PATHS_OPTION) === true &&

@@ -106,8 +115,20 @@ !this._addedDeprecatedRouter

_removeDeprecatedRouter() {
if (this._addedDeprecatedRouter) {
this._core.removeRouter(DEPRECATED_API_PATH, this._deprecatedApi.router);
this._addedDeprecatedRouter = false;
}
}
_addRouter() {
if (this._previousRoutersPath) {
this._core.removeRouter(this._previousRoutersPath, this._router);
this._removeRouter();
this._routersPath = this._settings.get(ADMIN_API_PATH_OPTION);
this._core.addRouter(this._routersPath, this._router);
}
_removeRouter() {
if (this._routersPath) {
this._core.removeRouter(this._routersPath, this._router);
this._routersPath = null;
}
this._previousRoutersPath = this._settings.get(ADMIN_API_PATH_OPTION);
this._core.addRouter(this._previousRoutersPath, this._router);
}

@@ -114,0 +135,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