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

kinto-node-test-server

v2.0.0

Published

A node API for operating a Kinto test server.

Downloads

102

Readme

kinto-node-test-server

Build Status

A Node and browser API for operating a Kinto test server providing the following features:

  • starting a server (optionally with supplementary configuration flags)
  • stopping a server
  • flushing a server
  • killing a running server

Note that a Python virtualenv must be installed in your project, and the kinto pip package installed within that environment.

Prerequisites

Node >= v10 is required.

Installation

$ npm install kinto-node-test-server --save-dev
$ virtualenv .venv -p python3
$ .venv/bin/pip install kinto

Please make sure to create an appropriately configured Kinto ini file.

Node API

Sample usage using mocha:

import KintoServer from "kinto-node-test-server";

describe("Test Kinto server", function() {
  let server;

  before(function() {
    server = new KintoServer("http://0.0.0.0:8888/v1", {
      kintoConfigPath: __dirname + "/kinto.ini",
    });
  });

  after(function() {
    server.killAll();
  });

  describe("Default test server", function() {
    beforeEach(function() {
      return server.start();
    });

    afterEach(function() {
      return server.stop();
    });

    it("should flush a server", function() {
      return server.flush().then(function() {
        console.log("yay flushed");
      });
    });
  });
});

CommonJS

If you're using the library in a CommonJS environment, you'll need to use the following to import the library:

const KintoServer = require("kinto-node-test-server").default;

Note that all KintoServer instance methods return Promises.

Browser API

The browser client follows the same API as the Node client. The browser client requires a proxy server, which you can launch with the following:

import { KintoProxyServer } from "kinto-node-test-server";

const server = new KintoProxyServer();
await server.startServer();

You can then connect to to the proxy server and use the same Node API with the following:

import KintoServer from "kinto-node-test-server";
// Note that the proxy server runs on port 8899
const server = new KintoServer("http://0.0.0.0:8899/v1");

Configuration

The KintoServer constructor requires the base URL of your kinto server instance and accepts an options object:

  • maxAttempts: The number of attempts retrying to connect to the server (default: 50)
  • kintoConfigPath: The path to your Kinto ini config file (default: __dirname + "/kinto.ini")
  • pservePath: The path to the .venv pserve executable (default: "pserve"); if the default value doesn't work, try ".venv/bin/pserve".

License

Apache 2.0