(Full description and list of commands at - https://npmjs.org/doc/index.html)
##List of less common (however useful) NPM commands
######Prepand ./bin to your $PATH Make sure to export your local $PATH and prepand relative ./node_modules/.bin/:
// The JavaScript functions always return something. If you don't specify something to return in the function then | |
// 'undefined' is returned by default | |
// So, console.log() will always return 'undefined' on node and chrome because the function doesn't return anything | |
let x; | |
let y = 3; | |
console.log(y); | |
// this console.log will return | |
// 3 |
// in exports_method.js | |
let add = (a, b) => a + b; | |
exports.add = add; // OR module.exports.add = add; | |
// in module_exports.js | |
let add = (a, b) => a + b; | |
module.exports = add; | |
// in caller.js |
// in express we can pass a callback to another callback using next | |
// for example if we need to choose between two response (if condition is made res.send else res.send) to do that we need to pass next() | |
// callback to else in our middleware | |
// in the auth_middleware.js | |
let authenticated = false; | |
let requireLogin = (req, res, next) => { | |
if (!authenticated) { | |
res.send('not logged in'); // res.redirect('/login'); | |
console.log('not logged'); |
The MIT License (MIT) | |
Copyright (c) 2015 Justin Perry | |
Permission is hereby granted, free of charge, to any person obtaining a copy of | |
this software and associated documentation files (the "Software"), to deal in | |
the Software without restriction, including without limitation the rights to | |
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | |
the Software, and to permit persons to whom the Software is furnished to do so, | |
subject to the following conditions: |
{ | |
"activites" : "activitiesTable", | |
"tasks" : { | |
"-KfbYYnJDdJ1IfQ4D6bl" : { | |
"firstname" : "palani", | |
"lastname" : "just lastname updated" | |
}, | |
"-KfpLsLVH59MpKXDdYVm" : { | |
"firstname" : "palaniraja", | |
"lastname" : "raja" |
// Node.js CheatSheet. | |
// Download the Node.js source code or a pre-built installer for your platform, and start developing today. | |
// Download: http://nodejs.org/download/ | |
// More: http://nodejs.org/api/all.html | |
// 0. Synopsis. | |
// http://nodejs.org/api/synopsis.html |
(Full description and list of commands at - https://npmjs.org/doc/index.html)
##List of less common (however useful) NPM commands
######Prepand ./bin to your $PATH Make sure to export your local $PATH and prepand relative ./node_modules/.bin/:
JavaScript is untyped, meaning that we can pass around data and objects as we want. | |
We can write code that calls methods that don't exist on an object, or variables that we don't have. | |
These problems are hard to discover when you are writing code and it can lead to unstable code, | |
and doing big changes of your code can become very difficult and risky as you don't immediately see if your changes | |
conflicts with the rest of the code. | |
TypeScript is mainly about adding types to JavaScript. That means that TypeScript requires you to accurately | |
describe the format of your objects and your data. When you do that, that means that the compiler can investigate | |
your code and discover errors. It can see that you are trying to call a function that does not exist or use a variable | |
that is not accessible in the current scope. |
var vehicle = function(ty) { | |
this.type=ty; | |
} | |
vehicle.prototype.ride = function() { | |
console.log('I am riding a ', this.type); | |
} | |
var newRebuild = function(constructor){ | |
var obj = {}; | |
Object.setPrototypeOf(obj, constructor.prototype); | |
var arArgs = Array.from(arguments).slice(1); |
Install mongodb
sudo apt-get install mongodb
Acess mongodb.service and insert the configuration code
cd /lib/systemd/system
sudo vim mongodb.service
[Unit]
Description=High-performance, schema-free document-oriented database
Documentation=man:mongod(1)