UNPKG

nmos-ledger

Version:

NMOS discovery and registration APIs

148 lines (113 loc) 4.73 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Source: NodeStore.js</title> <script src="scripts/prettify/prettify.js"> </script> <script src="scripts/prettify/lang-css.js"> </script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> </head> <body> <div id="main"> <h1 class="page-title">Source: NodeStore.js</h1> <section> <article> <pre class="prettyprint source linenums"><code>/* Copyright 2015 Christine S. MacNeill Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by appli cable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /** * Add a status code to an error object. * @param {Number} status Status code for the error. * @param {string} message Error message describing the error. * @return {Error} The newly created error with status set. */ function statsusError(status, message) { var e = new Error(message); e.status = status; return e; } /** * Generic store providing access to the current state of a node. * @interface */ function NodeStore() {} /** * Retrieve details of the node as the result of the callback. * @param {NodeStore~nodeCallback} cb Callback with the node result. */ NodeStore.prototype.getSelf = function(cb) { cb(statusError(500, 'Method getSelf must be implemented by extending NodeStore.')); } /** * Callback containing a single node result. * @callback NodeStore~nodeCallback * @param {Error} err Error retrieving the node's details. * @param {Node} result Node details. */ /** * Get all the devices available at this node. * @param {number=} skip Number of devices to skip before starting the listing. * @param {number=} limit Limit the number of values returned. * @param {NodeStore~devicesCallback} cb Callback providing the list of devlices. */ NodeStore.prototype.getDevices = function (skip, limit, cb) { cb(statusError(500, 'Method getDevices must be implemented by extending NodeStore.')); } /** * Callback to contain a list of devices. * @callback NodeStore~devicesCallback * @param {Error} err Error retrieving the list of devices. * @param {Device[]} result List of devices. * @param {number=} total Total number of devices. * @param {number=} pageOf Current page number. * @param {number=} size Number of items per page. Up to the provided limit. * @param {number=} pages Total number of pages. */ /** * Get the details of a specific device. * @param {String} id Identity of the device being queried. String as UUID. * @param {NodeStore~deviceCallback} cb Callback with the device result. */ NodeStore.prototype.getDevice = function (id, cb) { cb(statusError(500, 'Method getDevice must be implemented by extending NodeStore.')); } /** * Callback with the single requested device. * @callback NodeStore~deviceCallback * @param {Error} err Error retrieving the device's details. * @param {Device} result Single requested device. */ NodeStore.prototype.getSources = function (skip, limit, cb) { cb(statusError(500, 'Method getSources must be implemented by extending NodeStore.')); } NodeStore.prototype.getSource = function (id, cb) { cb(statusEroor(500, 'Method getSource must be implemented by extending NodeStore.')); } module.exports = NodeStore; </code></pre> </article> </section> </div> <nav> <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="NodeAPI.html">NodeAPI</a></li></ul><h3>Interfaces</h3><ul><li><a href="NodeStore.html">NodeStore</a></li></ul><h3>Global</h3><ul><li><a href="global.html#statsusError">statsusError</a></li></ul> </nav> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Sun Dec 20 2015 19:39:09 GMT+0000 (GMT) </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>