1.0.0 • Published 3 years ago

@faustbrian/node-hapi-json-rpc v1.0.0

Weekly downloads
-
License
AGPL-3.0-or-later
Repository
github
Last release
3 years ago

You can help the author become a full-time open-source maintainer by sponsoring him on GitHub.


@faustbrian/node-hapi-json-rpc

npm version

Installation

pnpm install @faustbrian/node-hapi-json-rpc

Usage

import * as plugin from "@faustbrian/node-hapi-json-rpc";
import Joi from "joi";

await server.register({
	plugin,
	options: {
		methods: [...],
		processor: {
			schema: Joi.object().keys({
				id: Joi.alternatives().try(Joi.number(), Joi.string()).required(),
				jsonrpc: Joi.string().allow("2.0").required(),
				method: Joi.string().required(),
				params: Joi.object(),
			}),
			validate(data: object, schema: object) {
				return Joi.validate(data, schema);
			},
		},
	},
});

License

This is an open-sourced software licensed under the AGPL-3.0-or-later.