Read Write Serve Plugin SDK

Develop high quality RWSERVE plugins

by Read Write Tools
Abstract
The RWSERVE Plugin SDK comprises a small collection of functions, classes, and enums that allow you to develop high quality plugins that adhere to the basic design of the HTTP/2 server software.

Motivation

Any RWSERVE plugin that you write will need a few basic tools in order to operate nicely within the server environment. Use of these is not mandatory. You are free to develop your plugin with your own set of helper functions.

Contents

  • log is a module for logging actions in a way that is compatible with the server's standard logging function.
  • SC is an enum for HTTP response status codes.
  • expect is a function for explicit argument type checking used in design by contract principles. It acts like a soft assertion, logging unmet expectations, but allowing your code to continue as best it can.

Download

The SDK is available from NPM. Before proceeding, you should already have Node.js and RWSERVE configured and tested.

This module should be installed on your web server in a well-defined place, so that it can be shared by all RWSERVE plugins. The standard location is /srv/rwserve-plugins.

cd /srv/rwserve-plugins
npm install rwserve-plugin-sdk

Usage

Use require within your codebase to access the SDK. Here's a simple demonstration of a plugin that uses the SDK:

const expect = require('rwserve-plugin-sdk').expect;
const log = require('rwserve-plugin-sdk').log;
const SC = require('rwserve-plugin-sdk').SC;

module.exports = class HelloWorldPlugin {
constructor(hostConfig) {
expect(hostConfig, 'HostConfig');
expect(hostConfig.hostname, 'String');
this.hostname = hostConfig.hostname;
Object.seal(this);
}
async startup() {
log.debug('HelloWorldPlugin', 'v1.0.0; © 2018 Read Write Tools; MIT License');
}
async shutdown() {
log.debug('HelloWorldPlugin', `Shutting down ${this.hostname}`);
}
async processingSequence(workOrder) {
expect(workOrder, 'WorkOrder');
try {
workOrder.addStdHeader('hello-world', this.hostname);
workOrder.setResponseBody(`Hello World ${this.hostname}`);
workOrder.setStatusCode(SC.OK_200);
}
catch (err) {
log.error(err.message);
}
}
}

Prerequisites

This is a plugin for the Read Write Tools HTTP/2 Server, which works on Linux platforms.

Software Minimum Version Most Recent Version
Ubuntu 16 Xenial Xerus 16 Xenial Xerus
Debian 9 Stretch 10 Buster
openSUSE openSUSE 15.1 openSUSE 15.1
Fedora Fedora 27 Fedora 32
CentOS CentOS 7.4 CentOS 8.1
RHEL RHEL 7.8 RHEL 8.2
RWSERVE RWSERVE 1.0.1 RWSERVE 1.0.47
Node.js Node.js 10.3 Node.js 12.17

License

The rwserve-plugin-sdk is licensed under the MIT License.

MIT License

Copyright © 2023 Read Write Tools.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Availability

Source code github
Package installation NPM
Documentation Read Write Hub

Read Write Serve Plugin SDK — Develop high quality RWSERVE plugins

🔗 🔎