Skip to content
Myr

Documenting plugins

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by visionmedia · committed by visionmedia · parent f21c1de · Browse files · 8 files+79 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

8 files+79 added−0 removed

  • other:+79 added−0 removed

8 files+79 added−0 removed

modified:lib/express/plugins/body-decoder.js+7 added
modified:lib/express/plugins/common-logger.js+5 added
modified:lib/express/plugins/content-length.js+5 added
modified:lib/express/plugins/cookie.js+17 added
modified:lib/express/plugins/hooks.js+17 added
28 unmodified lines
29// --- Hooks3031exports.Hooks = Plugin.extend({32 extend: {33 34 /**35 * Initialize extensions.36 */37 38 init: function() {39 process.mixin(GLOBAL, exports)40 }41 },42 43 // --- Events44 45 on: {46 47 /**48 * Invoke all before handlers.49 */50 51 request: function(event) {52 $(before).each(function(fn){53 fn.call(event.request)54 })55 },56 57 /**58 * Invoke all after handlers.59 */60 61 response: function(event) {62 $(after).each(function(fn){63 fn.call(event.request)64 })
3 unmodified lines
modified:lib/express/plugins/method-override.js+5 added
modified:lib/express/plugins/profiler.js+9 added
1 unmodified line
2// Express - Profiler - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)34exports.Profiler = Plugin.extend({5 on: {6 7 /**8 * Start timer.9 */10 11 request: function(event) {12 this.start = Number(new Date)13 },14 15 /**16 * Output duration.17 */18 19 response: function(event) {20 puts(event.request.method + ' ' + 21 event.request.uri.path + ': ' + 22 (Number(new Date) - this.start) + ' ms')
3 unmodified lines
modified:lib/express/plugins/redirect.js+14 added
1 unmodified line
2// Express - Redirect - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)34exports.Redirect = Plugin.extend({5 extend: {6 7 /**8 * Initialize extensions.9 */10 11 init: function() {12 Request.include({1314 /**
23 unmodified lines
38 } 39 })40 }41 },42 43 // --- Events44 45 on: {46 47 /**48 * Assign home to 'home', 'basepath' or '/'.49 * Assign back to 'referrer' or 'referer' headers.50 */51 52 request: function(event) {53 event.request.home = set('home') || set('basepath') || '/'54 event.request.back = event.request.header('referrer') || event.request.header('referer')55 }
2 unmodified lines