Skip to content

Commit

Permalink
fix(callback): callback is not required
Browse files Browse the repository at this point in the history
  • Loading branch information
mastilver committed Oct 6, 2015
1 parent 253f285 commit 4637ffd
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
10 changes: 8 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@ module.exports = function(app, paths, callback){

annotationRouter(paths, function(err, route){

if(err) return callback(err);
if(err) return callCallback(err);

app[route.method.toLowerCase()](route.url, route.action);
},
function(err){
callback(err);
callCallback(err);
});

function callCallback(err){
if(callback != null){
callback(err);
}
}
};
2 changes: 1 addition & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var expressRouter = require('../index.js');

var mockPath = 'mock.js';

describe('', function(){
describe('register routes', function(){

var app;

Expand Down
22 changes: 22 additions & 0 deletions test/no-callback.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
var should = require('should');
var express = require('express');

var expressRouter = require('../index.js');

var mockPath = 'mock.js';


describe('when no callback is given', function(){

var app;

before(function(){
app = express();
});

it('should not throw an error', function(done){
expressRouter(app, mockPath);

setTimeout(done, 1000);
})
})

0 comments on commit 4637ffd

Please sign in to comment.