Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions source/maintenance.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ function maintenance(app, options) {
};

var handle = function (req, res) {

var isApi = api && req.url.indexOf(api) === 0;

res.status(status);
Expand All @@ -69,10 +70,21 @@ function maintenance(app, options) {

var middleware = function (req, res, next) {
if (mode) {
return handle(req, res);
var request_url = req.url.split("?")[0];
if(request_url === url && ["DELETE","POST"].indexOf(req.method) != -1){
next();
}
else{
return handle(req, res);
}


}
else{
next();
}

next();

};

var inject = function (app) {
Expand Down
46 changes: 27 additions & 19 deletions test/spec/maintenence.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,15 @@ describe('maintenance.js', function () {
results = body;
done(err);
});

it('should return normal page', function () {
expect(response.statusCode).to.equal(200);
expect(results).to.equal('OK');
});

});

it('should return normal page', function () {
expect(response.statusCode).to.equal(200);
expect(results).to.equal('OK');
});



});

Expand Down Expand Up @@ -125,11 +127,13 @@ describe('maintenance.js', function () {
done(err);
});

it('should return normal page', function () {
expect(response.statusCode).to.equal(200);
expect(results).to.equal('OK');
});
});

it('should return normal page', function () {
expect(response.statusCode).to.equal(200);
expect(results).to.equal('OK');
});



});
Expand Down Expand Up @@ -177,10 +181,12 @@ describe('maintenance.js', function () {
done(err);
});

it('should return normal page', function () {
expect(response.statusCode).to.equal(200);
expect(results).to.equal('OK');
});

});

it('should return normal page', function () {
expect(response.statusCode).to.equal(200);
expect(results).to.equal('OK');
});


Expand Down Expand Up @@ -249,7 +255,9 @@ describe('maintenance.js', function () {

describe('and return back to normal', function () {
beforeEach(function (done) {
request.del(url + '/maintenance?access_key=secret', done);
request.del(url + '/maintenance?access_key=secret', function(err,resp,body){
done(err,body);
});
});

beforeEach(function (done) {
Expand All @@ -259,13 +267,13 @@ describe('maintenance.js', function () {
done(err);
});

it('should return normal page', function () {
expect(response.statusCode).to.equal(200);
expect(results).to.equal('OK');
});
});


it('should return normal page', function () {
expect(response.statusCode).to.equal(200);
expect(results).to.equal('OK');
});

});
});
});
Expand Down