Huge News!Announcing our $40M Series B led by Abstract Ventures.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

A mock server of Ctrip's apollo configuration service

  • 1.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Build Status Coverage

apollo-mock-server

A mock server of Ctrip's apollo configuration service.

This is a mock server only for testing, so it barely has any argument type checking and fault tolerance.

Install

$ npm i apollo-mock-server

Usage

const {ConfigService} = require('apollo-mock-server')

require('http').createServer(
  new ConfigService({
    pollingTimeout: 3000
  }).callback()
)
.listen(8888)

new ConfigService(options)

  • options Object
    • 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.

config.callback(): Function

Return a callback function suitable for the http.createServer() method to handle a request.

config.listen(port?): Promise<port>

  • port? number port to listen

Listen to a port. If port is not specified, it will get an available port by using get-port

Returns a promise of the port used

config.listen()
.then(port => {
  console.log(`server started at http://127.0.0.1:${port}`)
})

config.enableFetch(enable)

Enable or disable the API of get configurations, including both:

  • /configs
  • /configfiles

If disabled, the two APIs will both response with status 404

config.enableFetchError(enable)

If enabled, the two APIs above will response a bad JSON string

config.enableUpdateNotification(enable)

If disabled, the API /notifications/v2 will response with status 404

superAdmin

The admin client for super user

const {superAdmin} = require('apollo-mock-server')

superAdmin
.app('my-application')
.cluster('default')
.namespace('application')

// Changes the config value
.set('portal.elastic.cluster.name', 'hermes-es-jp')

// Emit update notifications
.publish()

License

MIT

Keywords

FAQs

Package last updated on 08 May 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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