Skip to content

Instantly share code, notes, and snippets.

You should really really use a framework (I recommend something like Express since it was battle-tested) unless you want to deal with sessions, cookies, middleware etc by yourself. Express is really light.
Starting the server with nohup: you shouldn't do that, just start it with the regular "node" command. Also Express wraps the routes in a try-catch, so your server won't crash in a route. However if your server does have a serious problem, you shouldn't fear restarting it (besides, if you have 2-3 processes at least, only one will die, so there will be at least 1-2 remaining and the user won't feel a thing).
For monitoring I personally prefer something more at the OS-level such as Upstart and Monit.
Hosting solution: since you already have your own serious hardware stuff, no need to invest money in something else. Just use a load-balancer (maybe nginx or node-http-proxy) to proxy stuff.
For Details Refer to https://stackoverflow.com/questions/8386455/deploying-a-production-node-js-server
#include <iostream>
using namespace std;
int main()
{
// bitwise operators
/*
bitwise operators are used to work on bits 0 , 1
126 = 1 * 10 ^ 2 + 2 * 10 ^ 1 + 6 * 10 ^ 0; // decimal system
#include <iostream>
using namespace std;
int main()
{
int a = 10;
int b = 5;
cout << a + b << endl; // addition
cout << a - b << endl; // substraction
#include <iostream>
using namespace std;
int main()
{
string name;
string surname;
cout << "Enter your name : ";
cin >> name;
cout << "Enter surname : ";
fetch('file url')
.then(function (response) {
return response.blob();
})
.then(function (blob) {
var fileURL = URL.createObjectURL(blob);
var w = window.open(fileURL);
w.print();
});
#include <iostream>
using namespace std;
int main()
{
int a,b,c;
short d = 10.5;
cout << "a : " << a << endl << "b : " << b << endl << "c : " << c << endl;
#include <iostream>
using namespace std;
// variables
// initialization
// allocating
// address
// Hungarian Notation
int main()
Refer to the link
"files.exclude": {
"node_modules/": true
}
"files.exclude": {
"**/._*": true
}
curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
sudo apt-get install -y nodejs
link : https://askubuntu.com/questions/426750/how-can-i-update-my-nodejs-to-the-latest-version
Object.keys(object).map(key => object[key]);
https://medium.com/chrisburgin/javascript-converting-an-object-to-an-array-94b030a1604c