npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

kong-mock-server

v1.3.0

Published

A mock server who behaves the same way as Kong's Admin APIs

Downloads

10

Readme

kong-mock-server

npm version

NPM NPM

It's a mock server who behaves the same way as Kong's Admin APIs. It's originally intended to test npm package kong-config-manager.

NOTE:

  1. This server would NOT check whether what you create for Kong is illegal or makes any sense. That's to say, it only does the basic APIs' stuff but NOT the full Kong's logic.

  2. Not all Admin APIs are mocked for now. Basically, APIs like GET all items and POST, PATCH or DELETE a item are supported. If you want more, please try to fork this repo and raise your PRs.

  3. The database instance of nedb here ONLY uses memory, so it can NOT persist your data. In other words, after the server stopped, all data would be flushed.

Usage

You have several choices:

As a git submodule

In this way, you don't need to download the npm package and require it, but just use it as a git submodule. See Git - git-submodule Documentation for more information about git submodule in case you haven't heard about it yet.

Then, run git submodule add [email protected]:Maples7/kong-mock-server.git to add it as a git submodule to your project.

The good thing of this way is you can start up the mock server via node kong-mock-server/index totally independently with listening on port 3001. Watch out the thread stuff.

There are some initial data we could insert into nedb for you in this way (see ./init-data). If you need them, add INIT_DATA=true before node <app> command just like NODE_ENV=production or use npm start.

You are welcome to see kong-config-manager for an example usage case of this way.

As a npm package

In this way, the package would export an Express instance created by const app = require('express')(). So if you use some test framework like ava, you no longer need to start up an independent server but just use the exported app to achieve your request and response stuff.

The exported app has a property nedb, created by Promise.promisifyAll(new Datastore()). See Promise.promisifyAll for more information about promisifyAll and usage of promisified APIs.

Use npm i kong-mock-server --save-dev to install it as a developing dependence package.

About Version

This project mocks version 0.10.x and 0.11.x(cluster endpoint disappears) of Kong (Although, API / always returns 200 - { version: '0.11.0' }), any other versions are NOT guaranteed. Theoretically, once the Admin APIs of Kong remain unchanged, it would work well. But again, nothing is determined for sure.

Relatives

License

GPLv3