-
-
Save hackhat/59cc74d88cc519997f8d to your computer and use it in GitHub Desktop.
Reusable services
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// api/v1/group/a.js | |
module.exports = function(args, cb, session){ | |
var bRes = this.f_api('v1.group.b', { | |
a: 5 | |
}).wait(); | |
cb(void 0, { | |
myData: bRes.someData | |
}); | |
} | |
module.exports.fibers = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// api/v1/group/b.js | |
module.exports = function(args, cb, session){ | |
var cRes = this.f_api('v1.group.c', { | |
b: args.a * 2 // Now we pass 5 * 2 = 10 | |
}).wait(); | |
cb(void 0, { | |
someData: cRes.c | |
}); | |
} | |
module.exports.fibers = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// api/v1/group/c.js | |
module.exports = function(args, cb, session){ | |
cb(void 0, {c: args.b * 2}); // 10 * 2 = 20; | |
} | |
module.exports.fibers = true; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment