Home Assignment #1 (Pirple's NodeJS Masterclass)
This is my submission project for the first assignment for the NodeJS masterclass.
- HTTP/HTTPS support
- NODE_ENV to toggle between debug modes
- Modularized code
- https POST request made to Yandex Translation API using the default NodeJS https module
- Every time you request /hello, it randomizes the message shown. If /hello?lang= is specified, then the Yandex API will translate it to that language.
- Solved a previous code-structure issue by using the Promise object to handle Async requests made to a third party.
- Replaced the callback() mechanism with a pathHandlerPromise object. This ensures that res object need not be passed to handlers and the callback code can be handled by the Promse itself.
To get the translator feature to work, add the following in the file ./config/private.json (The site still works without the translator, and just returns the message in English.)
{
"yandex_api_key" : "_your_api_key_"
}