Skip to content

Instantly share code, notes, and snippets.

View Godwin-NJ's full-sized avatar

Godwin Amadi Godwin-NJ

View GitHub Profile
@Godwin-NJ
Godwin-NJ / Download File with Node.md
Created August 1, 2023 11:24 — forked from gkhays/Download File with Node.md
Download a file from a URL using Node.js

Download File from URL

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.

Junior Backend Developer candidate test

Intro

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.

Technical guideline

Generic

@Godwin-NJ
Godwin-NJ / generate_env_config_file.sh
Created June 7, 2023 13:09 — forked from lezhkin11/generate_env_config_file.sh
Generate env-config.js based on .env file and ENVs variables. ENVs varibales overwrite .env
#!/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