-
Notifications
You must be signed in to change notification settings - Fork 1
/
Services.js
58 lines (50 loc) · 1.22 KB
/
Services.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
/**
* ## services
* provide plugged in functions from other rf-api-* modules
*/
var log = require('rf-log');
module.exports = {
// public var that holds all registred services
Services: {},
/** ### Register functions
* Example: register functions from other server modules
* ```js
* var Services = API.Services.Services;
* function createPdf(url, callback){
* createdPdfDoc(url, function(err, pdf){
* // callback always has the parameters mongoose like: err, docs
* callback(err, pdf)
* })
* }
* Services.register(createPdf)
* ```
*/
registerFunction: function (newFunction) {
var self = this;
var newFunctionName = newFunction.name;
if (!self.Services[newFunctionName]) {
self.Services[newFunctionName] = newFunction;
} else {
log.critical('tried to register function ' + newFunctionName + ' in API, it but already exists.');
}
}
};
/**
*
* ## Development
*
* Install the dev tools with
> npm install
*
* Then you can runs some test cases and eslint with:
*> npm test
*
* Generate Docs:
* > npm run-script doc
*
* ## To Do
* * testing
* ## Legal Issues
* * License: MIT
* * Author: Rapidfacture GmbH
*/