Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Change to checked-in and published JS.

  • Loading branch information...
commit de14722c3969f0dbcc6259d34279d48de39ef309 1 parent ef36f9d
@aseemk authored
Showing with 58 additions and 4 deletions.
  1. +54 −0 index.js
  2. +4 −4 package.json
View
54 index.js
@@ -0,0 +1,54 @@
+// Generated by CoffeeScript 1.3.3
+(function() {
+ var app, express, origAppUse, verb, wrapHandler, _fn, _i, _len, _ref,
+ __slice = [].slice;
+
+ module.exports = express = require('express');
+
+ wrapHandler = function(handler, isMiddleware) {
+ var makeCallback;
+ makeCallback = function(next) {
+ return function(err) {
+ if (err) {
+ return next(err);
+ } else if (isMiddleware) {
+ return next();
+ }
+ };
+ };
+ if (handler.length >= 4) {
+ return function(err, req, res, next) {
+ return handler(err, req, res, makeCallback(next));
+ };
+ } else {
+ return function(req, res, next) {
+ return handler(req, res, makeCallback(next));
+ };
+ }
+ };
+
+ app = express.HTTPServer.prototype;
+
+ origAppUse = app.use;
+
+ app.use = function(middleware) {
+ return origAppUse.call(this, wrapHandler(middleware, true));
+ };
+
+ _ref = ['all', 'get', 'post', 'put', 'del', 'error'];
+ _fn = function(verb) {
+ var origAppVerb;
+ origAppVerb = app[verb];
+ return app[verb] = function() {
+ var args;
+ args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
+ args[args.length - 1] = wrapHandler(args[args.length - 1]);
+ return origAppVerb.apply(this, args);
+ };
+ };
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ verb = _ref[_i];
+ _fn(verb);
+ }
+
+}).call(this);
View
8 package.json
@@ -2,17 +2,17 @@
, "description": "Express monkey-patch to support Streamline syntax."
, "version": "0.0.0"
, "author": "Aseem Kishore <aseem.kishore@gmail.com>"
-, "dependencies":
+, "dependencies": {}
+, "devDependencies":
{ "coffee-script": "~1.3.3"
}
-, "devDependencies": {}
, "engines":
{ "node": "*"
}
, "scripts":
{ "build": "coffee -c ."
- , "clean": "rm -f *.js"
- , "postinstall": "npm run build"
+ , "watch": "coffee -w -c ."
+ , "prepublish": "npm run build"
}
, "homepage": "https://github.com/aseemk/express-streamline"
, "repository":
Please sign in to comment.
Something went wrong with that request. Please try again.