{"_id":"njrpc","_rev":"21-18382977e672af02b7178fcd937d3232","name":"njrpc","description":"JSON-RPC v2.0 implementation in NodeJS","dist-tags":{"latest":"1.1.1"},"versions":{"1.0.1":{"author":{"name":"Long Ho","email":"holevietlong@gmail.com","url":"www.azndezign.com"},"name":"njrpc","description":"JSON-RPC v2.0 implementation in NodeJS","version":"1.0.1","repository":{"type":"git","url":"git://github.com/longlho/node-jsonrpc.git"},"main":"jrpc.js","engines":{"node":">= v0.4.0"},"dependencies":{},"devDependencies":{},"scripts":{"test":"node test/test.js"},"_npmUser":{"name":"longlho","email":"holevietlong@gmail.com"},"_id":"njrpc@1.0.1","_engineSupported":true,"_npmVersion":"1.0.104","_nodeVersion":"v0.6.0","_defaultsLoaded":true,"dist":{"shasum":"eedbbd255caf5e6365a98402184f1d2b46fbf306","tarball":"https://registry.npmjs.org/njrpc/-/njrpc-1.0.1.tgz","integrity":"sha512-2AhZw/CmFKepx/ZVam5hDLWQB93Z20ADPc+M7VIW+95wg5oupowwJdPkbLbuyIYVjCFkQ0MIgG1HYP5ExIHM7g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDOtC0nUpq+PI7yRe/3WY+ytIiCjIRYT4QxicXt5ECP2wIhAOsM3q8oKvESGdZZaljBHSq3dCbNv4X61N0dti4HL91f"}]},"maintainers":[{"name":"longlho","email":"holevietlong@gmail.com"}],"directories":{}},"1.0.2":{"author":{"name":"Long Ho","email":"holevietlong@gmail.com","url":"www.azndezign.com"},"name":"njrpc","description":"JSON-RPC v2.0 implementation in NodeJS","version":"1.0.2","repository":{"type":"git","url":"git://github.com/longlho/node-jsonrpc.git"},"main":"njrpc.js","engines":{"node":">= v0.4.0"},"dependencies":{},"devDependencies":{},"scripts":{"test":"node test/test.js"},"_npmUser":{"name":"longlho","email":"holevietlong@gmail.com"},"_id":"njrpc@1.0.2","_engineSupported":true,"_npmVersion":"1.0.104","_nodeVersion":"v0.6.0","_defaultsLoaded":true,"dist":{"shasum":"0c63f3bb23412519a9897ee005182a950e9adb1f","tarball":"https://registry.npmjs.org/njrpc/-/njrpc-1.0.2.tgz","integrity":"sha512-sW9Iz7LVmJsMwqRCrdRMghdfkSt/j8v92g5zUqr14Mv6AhRAtHLa3zvqvmiQAI8gMyovZLQRCExSKQtUAAn8ZQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICBWjHqlq5xK1rcpVgBqFRGJD1cnpbcRYNjIzAnwWE/EAiAveF5AveWyWDpeWxImZyTh+XZ4stJZu9HMwisErXRV4g=="}]},"maintainers":[{"name":"longlho","email":"holevietlong@gmail.com"}],"directories":{}},"1.0.3":{"author":{"name":"Long Ho","email":"holevietlong@gmail.com","url":"www.azndezign.com"},"name":"njrpc","description":"JSON-RPC v2.0 implementation in NodeJS","version":"1.0.3","repository":{"type":"git","url":"git://github.com/longlho/node-jsonrpc.git"},"main":"njrpc.js","engines":{"node":">= v0.4.0"},"dependencies":{},"devDependencies":{"vows":"latest"},"scripts":{"test":"node test/test.js"},"_npmUser":{"name":"longlho","email":"holevietlong@gmail.com"},"_id":"njrpc@1.0.3","_engineSupported":true,"_npmVersion":"1.0.106","_nodeVersion":"v0.6.6","_defaultsLoaded":true,"dist":{"shasum":"65f732bcfb08d1c51d3a2572f901ccc5817fa6b9","tarball":"https://registry.npmjs.org/njrpc/-/njrpc-1.0.3.tgz","integrity":"sha512-59Ig+its1Ymp5SiinHPBrc7h0rMjCU9xUggA7gwKL6ToOOcz/eo8hIEWgacSqGGaN47esrMnPX8+JRRuMLiqdQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDAlMeMUjbDV1q0dxp2C3nrul0VL3QjiNSwuKekSQZs/AIgMX3b0jGB+6fCW5boRs0EbcPU1FCcPatqc0X3C1Ja0PA="}]},"maintainers":[{"name":"longlho","email":"holevietlong@gmail.com"}]},"1.0.4":{"author":{"name":"Long Ho","email":"holevietlong@gmail.com","url":"www.azndezign.com"},"name":"njrpc","description":"JSON-RPC v2.0 implementation in NodeJS","version":"1.0.4","repository":{"type":"git","url":"git://github.com/longlho/node-jsonrpc.git"},"main":"njrpc.js","engines":{"node":">= v0.4.0"},"dependencies":{},"devDependencies":{"vows":"latest"},"scripts":{"test":"vows test/test.js --spec"},"_npmUser":{"name":"longlho","email":"holevietlong@gmail.com"},"_id":"njrpc@1.0.4","_engineSupported":true,"_npmVersion":"1.0.104","_nodeVersion":"v0.6.0","_defaultsLoaded":true,"dist":{"shasum":"594b614588d14c000f1fa73333241aecbea546d4","tarball":"https://registry.npmjs.org/njrpc/-/njrpc-1.0.4.tgz","integrity":"sha512-6YUEmcq91A79EiKB9XYt6fMwLxu0g5U2uI55QfkHfhdJIXeMcsLudLA+8Wgr+UySaEDizMcGAKnlZj0PUuZR3A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDjeVoBh1pB4AQMzKB6fMatYoyntu7MeTb5+RGLlcJvFAIgO6NLzStvJ/lsQjOzrhfeppFY7PS0OXzlkXYbEl3JM5k="}]},"maintainers":[{"name":"longlho","email":"holevietlong@gmail.com"}]},"1.1.1":{"author":{"name":"Long Ho","email":"holevietlong@gmail.com","url":"www.azndezign.com"},"contributors":[{"name":"Krasen Borisov @kraz"}],"name":"njrpc","description":"JSON-RPC v2.0 implementation in NodeJS","version":"1.1.1","repository":{"type":"git","url":"git://github.com/longlho/node-jsonrpc.git"},"main":"njrpc.js","engines":{"node":">= v0.6.0"},"dependencies":{},"devDependencies":{"vows":"latest"},"scripts":{"test":"vows test/test.js --spec"},"_npmUser":{"name":"longlho","email":"holevietlong@gmail.com"},"_id":"njrpc@1.1.1","optionalDependencies":{},"_engineSupported":true,"_npmVersion":"1.1.24","_nodeVersion":"v0.6.19","_defaultsLoaded":true,"dist":{"shasum":"1d44be12a65f755176b70938d7bf0999aa705d30","tarball":"https://registry.npmjs.org/njrpc/-/njrpc-1.1.1.tgz","integrity":"sha512-mP9PK3q16gPDdaHgbEdKQ91R5L0MtWivSDtM26ttvBHJCmcqyUBez24JSq96HPia7zbPiBNQW07WSIMwmaCPaQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCID6aLhF7BfUmufAKngSY/4LyKz0m2FEx5aSzyBFFSdAeAiEA2f6zjNFi1RwA2uhraeWD1osMPRSZZxT3y6eg440cIwE="}]},"maintainers":[{"name":"longlho","email":"holevietlong@gmail.com"}]}},"readme":"# Overview\nThis is a JSON-RPC protocol implementation in NodeJS that follows JSON-RPC 2.0 specs. The good and also bad thing about this library is that it enforces method handler modules to have a certain convention/design pattern. However, it allows the server to automatically extract documentation from the handler (Introspection). This library is still under development.\n\n## Features\n- Handles GET/POST requests\n- Better error feedback\n- Allows method namespacing (Module.method)\n- Allows exposure of all methods inside a module\n- Authentication can be achieved by giving a preHandle function\n- Introspection (in progress)\n\n## Installation\nThe usual `npm install njrpc` or if you prefer, you can grab the source/fork it and make changes yourself.\n\n## Usage\nHandlers that can be registered with njrpc should have a name attribute in the instance. A sample handler can be found in handler.js.\n\nThe best design pattern to use with this server is the Module design pattern.\n\n### njrpc.register(modules)\nRegisters an array of modules/a single module, which should have `name` as the namespace of the module.\n\n### njrpc.addCustomPath(url, handlerFn)\nAdd `handlerFn` to a custom path, for example '/version' can return the version number as plain text instead of a JSON request.\n`handlerFn` will have 2 arguments:             \n\n- `req`: Request object\n- `res`: Response object to write to\n\n### njrpc.output(res, [jsonResponse])\nActually write the JSON response out to the pipe. This can also be overridden to write something else.\n\n### njrpc.handle(req, res, [preHandleFn])\nHandles a request & response, JSON-RPC style. `preHandleFn` is used to manipulate the JSON request before it gets pushed down to the Handler level. `preHandleFn` takes a single JSON request object as the argument (after parsing and whitelisting)\n\n## Examples\n\n### Simple EchoHandler that echoes whatever it receives\n\n\tvar EchoHandler = function () {\n\t\t\treturn {\n\t\t\t\tname : 'EchoHandler',\n\t\t\t\techo : function (str) {\n\t\t\t\t\treturn str;\n\t\t\t\t}\n\t\t\t};\n\t\t},\n\t\tjrpcServer = require('./njrpc'),\n\t\thttp = require('http');\n\t\n\tjrpcServer.registerModule(new EchoHandler());\n\thttp.createServer(function(req, res) {\n\t\tjrpcServer.handle(req, res);\t\n\t}).listen(8080);\n\t\n### Authenticated Echo Handler that still echoes, but needs a user & token\n\n\tvar AuthenticatedEchoHandler = function () {\n\t\t\treturn {\n\t\t\t\tname : 'AuthenticatedEchoHandler',\n\t\t\t\techo : function(context, str) {\n\t\t\t\t\tif (!context.user || !context.token) {\n\t\t\t\t\t\tthrow new Error(\"This call is unauthenticated\");\n\t\t\t\t\t}\n\t\t\t\t\treturn str;\n\t\t\t\t}\n\t\t\t};\n\t\t},\n\t\tpreHandler = function (jsonReq) {\n\t\t\tif (jsonReq.headers) {\n\t\t\t\tif (Array.isArray(jsonReq.params)) {\n\t\t\t\t\tjsonReq.params.unshift(jsonReq.headers);\n\t\t\t\t} else {\n\t\t\t\t\tjsonReq.params.context = jsonReq.headers;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tjrpcServer = require('./njrpc'),\n\t\thttp = require('http');\n\t\n\tjrpcServer.registerModule(new AuthenticatedEchoHandler());\n\thttp.createServer(function(req, res) {\n\t\tjrpcServer.handle(req, res, preHandler);\t\n\t}).listen(8080);\n\n","maintainers":[{"name":"longlho","email":"holevietlong@gmail.com"}],"time":{"modified":"2022-06-21T10:26:05.161Z","created":"2011-11-09T18:56:26.142Z","1.0.1":"2011-11-09T18:56:26.685Z","1.0.2":"2011-12-04T22:06:48.665Z","1.0.3":"2011-12-24T18:51:43.999Z","1.0.4":"2012-02-29T04:51:49.125Z","1.1.1":"2012-06-25T13:46:16.038Z"},"author":{"name":"Long Ho","email":"holevietlong@gmail.com","url":"www.azndezign.com"},"repository":{"type":"git","url":"git://github.com/longlho/node-jsonrpc.git"}}