swish-http

0.3.3 • Public • Published

Swish HTTP

This module provides a Swish store in the browser that forwards requests over HTTP to a Swish store on the server.

In the browser

The file client.js can be included on its own (where it will register the global class SwishHttp). If used from AMD or CommonJS it will define a module, e.g.

var SwishHttp = require('swish-http/client');

To set up a store, provide the URL endpoint:

var store = new SwishHttp('/json/my-store');

On the server

The main module (index.js) provides the counterpart for the server. You construct the a wrapper using an existing Swish store:

var wrapper = require('swish-http')(store);

You can then register this as an Express middleware at the appropriate location:

app.use('/json/my-store', wrapper.express());

Testing

The tests run in the browser. There is an Express-based test server in test/index.js which serves a single page (on some available port) and some JavaScript files.

The test page/server creates a fresh store for each test, and has no cleanup, so the test server should not run indefinitely.

You can start this server using npm run test-server.

If you append the fragment #stopOnFirst to the page, it will halt at the first failed test, instead of continuing testing.

Readme

Keywords

Package Sidebar

Install

npm i swish-http

Weekly Downloads

0

Version

0.3.3

License

MIT

Last publish

Collaborators

  • geraintluff