Skip to content

Instantly share code, notes, and snippets.

// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
//optional
//Takes an interface and enforces its keys but optionally.
//SO SO handy!
type Partial<T> = {
[p in keyof T]?: T[p]
}
@adam-cyclones
adam-cyclones / gist:326c2795182694502fdd71ce111922a5
Created January 29, 2017 13:45
Inject / Intercepting Express 4 res.render with ES6
//custom middlewhare
mount.use( function( req, res, next ) {
//trap any render function call for this mount
res.render = new Proxy(res.render,{
apply(target, thisArg, argumentsList){
//DI data intercept
//BEWARE, i have not added if statements for the potential render arguments
//push a callback
//you could push a data object here.
//you could even catch errors and render that!