One of Apexlab's strategic partners, Olvasoegylet.io sent us a request for a book catalog application. They would like to have a public collection of books for their customers. You are the chosen one who may write POC (proof of concept) purely back-end (Node) JavaScript (Typescript) application which they could use to provide data for their various mobile application eg.: Book Renter.
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
#!/bin/sh | |
# line endings must be \n, not \r\n ! | |
# Writes JS code which opens object literal and assigns it to the global window object. | |
# Reads each line of .env file and splits into key/value pair. | |
# Looks for the environment variable, if set, uses its value, otherwise, uses the default value from .env file. | |
# Removes all carriage returns (\r) | |
# Append it to object that we assigned to global window object. | |
# Close object literal | |
echo "window.env = {" > ./env-config.js |
Proof-of-concept to download a file from a URL and save it locally. For example, I may wish to retrieve a JAR file from Nexus.
Uses the http
package, which does the basics with raw HTTP protocol support.
Possible update: use request
, it is like the Python's requests library. There is a companion package called node-request-progress
that tracks download progress. See request-progress on GitHub.
Note: The request package has been deprecated.