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.
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.
Answer: All APIs of Node.js library are aynchronous that is non-blocking. It essentially means a Node.js based server never waits for a API to return data. Server moves to next API after calling it and a notification mechanism of Events of Node.js helps server to get response from the previous API call.
Source: tutorialspoint.com
const express = require('express'); | |
const session = require('express-session'); | |
const redis = require('redis'); | |
const connectRedis = require('connect-redis'); | |
const app = express(); | |
// if you run behind a proxy (e.g. nginx) | |
// app.set('trust proxy', 1); |
Steps to deploy a Node.js app to DigitalOcean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt
If you use the referal link below, you get $10 free (1 or 2 months) https://m.do.co/c/5424d440c63a
I will be using the root user, but would suggest creating a new user
var dotenv = require('dotenv'); | |
dotenv.config(); | |
var fs = require('fs'); | |
var cloudinary = require('cloudinary').v2; | |
const http = require('http'); | |
const uploadDir = 'uploadfiles/'; | |
if (!fs.existsSync('uploadfiles')) { | |
fs.mkdirSync('uploadfiles'); | |
} |
#!/bin/sh | |
# line endings must be \n, not \r\n ! | |
echo "window._env_ = {" > ./env-config.js | |
awk -F '=' '{ print $1 ": \"" (ENVIRON[$1] ? ENVIRON[$1] : $2) "\"," }' ./.env >> ./env-config.js | |
echo "}" >> ./env-config.js |
This sheet goes along with this SSH YouTube tutorial
$ ssh brad@192.168.1.29
$ mkdir test
$ cd test
object getProp(object source, string name) | |
{ | |
var type = source.GetType(); | |
var prop = type.GetProperty(name); | |
return prop.GetValue(source); | |
} |