VirusTotalNet
VirusTotalNet copied to clipboard
Handler.js can return a promise
Signed-off-by: Patricio Díaz [email protected]
Index.js can handle is handler.js returns either a final value or a promise
Description
Added code to index.js tu verify if the value returned by handler is a promise, if so first resolves it to get the final value to return.
Motivation and Context
Many users ask for using promises or async/await to handle asynchrony.
- [x] I have raised an issue to propose this change (required)
Which issue(s) this PR fixes
Fixes #92
How Has This Been Tested?
For normal behavior, handler returning final value:
While in the templates folder created a function with
$ faas-cli new promise-test --lang node
Deployed with
$ faas-cli up -f promise-test.yml
Checked that it works using Portal
For cheking when handler returns a promise:
At handler.js, commented the actual module.exports and uncommented the sugested one that returns a promise.
Deployed again and test with Portal
Types of changes
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
Checklist:
- [x] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [x] I've read the CONTRIBUTION guide
- [x] I have signed-off my commits with
git commit -s
- [ ] I have added tests to cover my changes.
- [ ] All new and existing tests passed.