forked from bitpay/insight
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservice.js
91 lines (74 loc) · 1.82 KB
/
service.js
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
'use strict';
var util = require('util');
var EventEmitter = require('events').EventEmitter;
var Service = function(options) {
EventEmitter.call(this);
this.node = options.node;
this.name = options.name;
};
util.inherits(Service, EventEmitter);
/**
* Describes the dependencies that should be loaded before this service.
*/
Service.dependencies = [];
/**
* blockHandler
* @param {Block} block - the block being added or removed from the chain
* @param {Boolean} add - whether the block is being added or removed
* @param {Function} callback - call with the leveldb database operations to perform
*/
Service.prototype.blockHandler = function(block, add, callback) {
// implement in the child class
setImmediate(function() {
callback(null, []);
});
};
/**
* the bus events available for subscription
* @return {Array} an array of event info
*/
Service.prototype.getPublishEvents = function() {
// Example:
// return [
// ['eventname', this, this.subscribeEvent, this.unsubscribeEvent],
// ];
return [];
};
/**
* the API methods to expose
* @return {Array} return array of methods
*/
Service.prototype.getAPIMethods = function() {
// Example:
// return [
// ['getData', this, this.getData, 1]
// ];
return [];
};
// Example:
// Service.prototype.getData = function(arg1, callback) {
//
// };
/**
* Function which is called when module is first initialized
*/
Service.prototype.start = function(done) {
setImmediate(done);
};
/**
* Function to be called when bitcore-node is stopped
*/
Service.prototype.stop = function(done) {
setImmediate(done);
};
/**
* Setup express routes
* @param {Express} app
*/
Service.prototype.setupRoutes = function(app) {
// Setup express routes here
};
Service.prototype.getRoutePrefix = function() {
return this.name;
};
module.exports = Service;