New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

apollo-mock-server

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apollo-mock-server - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

3

package.json
{
"name": "apollo-mock-server",
"version": "1.1.1",
"version": "1.2.0",
"description": "A mock server of Ctrip's apollo configuration service",

@@ -46,2 +46,3 @@ "main": "src/index.js",

"core-util-is": "^1.0.2",
"delay": "^4.2.0",
"get-port": "^5.0.0",

@@ -48,0 +49,0 @@ "koa": "^2.7.0",

@@ -45,2 +45,3 @@ [![Build Status](https://travis-ci.org/kaelzhang/apollo-mock-server.svg?branch=master)](https://travis-ci.org/kaelzhang/apollo-mock-server)

- **pollingTimeout** `number=60000` If there is no update notifications in `options.pollingTimeout` milliseconds, then config service will tell the client with status `304`
- **configDelay** `number=0` The APIs to get the configuration will be delayed in `configDelay`. This option is to mimic the timeout scenarios.

@@ -47,0 +48,0 @@ ### config.callback(): Function

const {parse} = require('url')
const delay = require('delay')
const {BaseService} = require('./class')

@@ -6,3 +7,4 @@

constructor ({
pollingTimeout = 60000
pollingTimeout = 60000,
configDelay = 0
}) {

@@ -13,2 +15,3 @@ super({

this._configDelay = configDelay
this._fetchDisabled = false

@@ -38,3 +41,5 @@ this._fetchError = false

_route (router) {
router.get('/configs/:appId/:cluster/:namespaceName', ctx => {
router.get('/configs/:appId/:cluster/:namespaceName', async ctx => {
await delay(this._configDelay)
if (this._fetchError) {

@@ -91,32 +96,37 @@ ctx.body = '{boooooooooooooom!}'

router.get('/configfiles/json/:appId/:cluster/:namespaceName', ctx => {
if (this._fetchError) {
ctx.body = '{boooooooooooooom!}'
return
}
router.get(
'/configfiles/json/:appId/:cluster/:namespaceName',
async ctx => {
await delay(this._configDelay)
if (this._fetchDisabled) {
ctx.status = 404
return
}
if (this._fetchError) {
ctx.body = '{boooooooooooooom!}'
return
}
const {
appId,
cluster,
namespaceName
} = ctx.params
if (this._fetchDisabled) {
ctx.status = 404
return
}
const namespace = this._config
.app(appId)
.cluster(cluster)
.namespace(namespaceName)
const {
appId,
cluster,
namespaceName
} = ctx.params
if (!namespace.published()) {
ctx.status = 404
return
const namespace = this._config
.app(appId)
.cluster(cluster)
.namespace(namespaceName)
if (!namespace.published()) {
ctx.status = 404
return
}
ctx.body = namespace.configurations
}
)
ctx.body = namespace.configurations
})
router.get('/notifications/v2', async ctx => {

@@ -123,0 +133,0 @@ if (this._notificationError) {

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