var fs = require("fs");
let moduleConfiguration = JSON.parse(fs.readFileSync('moduleConfiguration.json', 'utf8'));
module.exports = function(driver) {
/**
* Log listing
* @param {string} start device object to subscribe the platform to the log
* @param {string} end device object to subscribe the platform to the log
* @callback {Function} callback Callback function
* @param {Error|string} err Error object
* @param {logEntry} result Result object
*/
driver.logs = function(start, end, callback) {
// Replace the code below with your implementation.
// Please make sure the callback is invoked.
process.nextTick(function() {
var err = new Error('Not implemented');
callback(err);
});
/*
var err0 = new Error('Invalid input');
err0.statusCode = 405;
return cb(err0);
*/
}
/**
* Return the endpoints available in the Driver Component
* @callback {Function} callback Callback function
* @param {Error|string} err Error object
* @param {getMetadata_response_200} result Result object
*/
driver.getMetadata = function(callback) {
let driverMetadata = require("../driverImplementation/"+ moduleConfiguration.driver)().getDriverMetadata();
callback(null, driverMetadata);
/*
var err0 = new Error('Invalid input');
err0.statusCode = 405;
return cb(err0);
*/
}
driver.remoteMethod('logs',
{ isStatic: true,
consumes: [ 'application/json' ],
produces: [ 'application/json' ],
accepts:
[ { arg: 'start',
type: 'string',
description: 'device object to subscribe the platform to the log',
required: true,
http: { source: 'path' } },
{ arg: 'end',
type: 'string',
description: 'device object to subscribe the platform to the log',
required: true,
http: { source: 'path' } } ],
returns:
[ { description: 'id of the device created',
type: 'logEntry',
arg: 'data',
root: true } ],
http: { verb: 'get', path: '/logs' },
description: 'Log listing' }
);
driver.remoteMethod('getMetadata',
{ isStatic: true,
produces: [ 'application/json' ],
accepts: [],
returns:
[ { description: 'manifest',
type: 'getMetadata_response_200',
arg: 'data',
root: true } ],
http: { verb: 'get', path: '/metadata' },
description: 'Return the endpoints available in the Driver Component' }
);
}