Skip to content

Instantly share code, notes, and snippets.

View Godwin-NJ's full-sized avatar

Godwin Amadi Godwin-NJ

View GitHub Profile

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

@gkhays
gkhays / Download File with Node.md
Created February 27, 2020 17:26
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.

Interview Questions

Node.js

Q1: What do you mean by Asynchronous API? ☆☆

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

@productioncoder
productioncoder / index.js
Last active October 13, 2023 18:45
Session-based authentication in express.js
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);
@bradtraversy
bradtraversy / node_nginx_ssl.md
Last active April 30, 2024 08:44
Node app deploy with nginx & SSL

Node.js Deployment

Steps to deploy a Node.js app to DigitalOcean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt

1. Sign up for Digital Ocean

If you use the referal link below, you get $10 free (1 or 2 months) https://m.do.co/c/5424d440c63a

2. Create a droplet and log in via ssh

I will be using the root user, but would suggest creating a new user

@sobingt
sobingt / download.js
Last active September 12, 2023 22:00
Download file from cloudinary
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');
}
@kunokdev
kunokdev / env.sh
Last active June 7, 2023 13:04
Reads each line of .env file, uses env var value is set, otherwise default value from .env file itself
#!/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
@bradtraversy
bradtraversy / ssh.md
Last active April 24, 2024 18:07
SSH & DevOps Crash Course Snippets

SSH Cheat Sheet

This sheet goes along with this SSH YouTube tutorial

Login via SSH with password (LOCAL SERVER)

$ ssh brad@192.168.1.29

Create folder, file, install Apache (Just messing around)

$ mkdir test

$ cd test

@lmcneel
lmcneel / remove-node-modules.md
Last active April 21, 2024 19:39
How to remove node_modules after they have been added to a repo

How to remove node_modules

Create a .gitignore file

  1. Check for an existing .gitignore file in the project directory
ls -a
@ShvedAction
ShvedAction / AnonimusObjectGetProperty.cs
Last active February 14, 2024 23:55
C# Reflection: How to get access to property of anonymous objects.
object getProp(object source, string name)
{
var type = source.GetType();
var prop = type.GetProperty(name);
return prop.GetValue(source);
}