Skip to content

Instantly share code, notes, and snippets.

-global
- log 127.0.0.1 local0
- log 127.0.0.1 local1 notice
-
-
-defaults
- mode http
- option httplog
- option dontlognull
- timeout connect 5000
export default (config) => ({
compiler_public_path: `http://${config.server_host}:${config.server_port}/`,
proxy: {
enabled: true,
options: {
// koa-proxy options
host: 'http://localhost:4000',
match: /^\/api\/.*/
}
}
@abhinavdhasmana
abhinavdhasmana / server.js
Created January 3, 2017 04:02
Example of memory leak in node.js using singleton pattern
'use strict';
const Hapi = require('hapi');
const server = new Hapi.Server();
server.connection({ port: 3000 });
const myBigFatArray = [];
server.route({
'use strict';
function whoAmI() {
console.log(this);
}
whoAmI();
// Output => undefined
'use strict';
function whoAmI() {
console.log('I am in local scope:', this);
}
console.log('I am in global scope:', this);
whoAmI();
// Output in Node
// I am in global scope: {}
'use strict';
function whoAmI() {
console.log('I am in local scope:', this);
function insideFunction() {
console.log('I am an inside function:', this);
}
insideFunction();
}
'use strict';
function whoAmI() {
console.log('I am in local scope:', this);
function insideFunction() {
console.log('I am an inside function:', this);
}
insideFunction();
}
this.myName = 'Abhinav';
'use strict';
function whoAmI() {
console.log('I am in local scope:', this);
function insideFunction() {
console.log('I am an inside function:', this);
}
insideFunction.apply(this);
}
this.myName = 'Abhinav';
'use strict';
function whoAmI() {
console.log('I am in local scope:', this);
this.insideFunction = function () {
console.log('I am an inside function:', this);
}
this.insideFunction();
}
this.myName = 'Abhinav';
'use strict'
const testObj = {
a: 10,
whoamI: function() {
console.log(this);
}
};
testObj.whoamI();