//in path/to/controller
var express = require('express');
var router = express.Router();
router.get('/login', require('path/to/loginMiddleware'));
router.post('/login', require('path/to/loginPostMiddleware'));
router.get('/some/other/route', require('path/to/otherRouteMiddleware'));
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
- Cherry picking args to invoke can lose the
this
context if it were a class instance.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//the pluginSpec from the instrument module | |
var plugin = { | |
name: 'aPLugin', | |
spec: { | |
'onTransport': { | |
'clients' : 'someClient' /*or*/ ['clienta', 'clientb', 'clientc' ...] /*or * if none specified */, | |
'action': 'exec:./doSomething' | |
}, | |
'onStats': | |
{ |
Ability to :
- set up a logger before lifecycle events of a kraken app - like when requiring some utility files, talking to services outside of app startup events.
- ability to add category for a logger in addition to tagging them.
- maybe even add capability based on specific labels on logging events ? unsure if we need multiple levels of filtering enabled
- Small functions < 30 lines
- Monomorphic (preferable same type arguments)
- Dont leak 'arguments' or dont pass it around
- While working with modifying big arrays, better to for loop through it than create new arrays to modify it (apparently iterating is much faster than memory allcocation time)
I hereby claim:
- I am pvenkatakrishnan on github.
- I am pvenkatakrishnan (https://keybase.io/pvenkatakrishnan) on keybase.
- I have a public key whose fingerprint is E132 0585 11D8 B8B3 A464 B889 FD38 BC72 3297 F41D
To claim this, I am signing this object:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// make a config object use a confit factory in order to merge two configs | |
exports.create = function create(options) { | |
var deferred, protocols, baseFactory, appFactory; | |
deferred = q.defer(); | |
protocols = createHandlers(options); | |
//create a baseFactory | |
baseFactory = confit({ basedir: path.join(path.dirname(__dirname), 'config'), protocols: protocols }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function generateConfig(baseDir, protocols, overrides) { | |
var deferred, factory; | |
deferred = q.defer(); | |
factory = confit({ basedir: baseDir, protocols: protocols }); | |
overrides.forEach(function(entry) { | |
factory.override(entry); | |
}); | |
factory.create(function (err, config) { | |
var ovride; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//the rule evaluation function is determined by properties: api || (module & api) | |
//the arguments passed to the api will be (req,rules) | |
//where rules is the property *rules* in ruleSet | |
//if just api is set, then rule engine would invoke that function with arguments assuming it is accessible in the namespace | |
//if module + api is set, then rule engine would require that module and invoke speced api on it. | |
//if neither module nor api is set, then the rule engine will try to evaluate on locals | |
//the rule implementation should return true/false | |
//rules will be evaluated with a switch case mentality. WHichever evaluates to truthy first will win |
NewerOlder