Parent: [49b297] (diff)

Download this file

driver.js    92 lines (75 with data), 2.4 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
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' }
);
}