Skip to content

Commit

Permalink
tweak and bump to 0.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
troygoode committed Apr 28, 2013
1 parent bd357b7 commit dec52de
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 16 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var express = require('express')
, cors = require('cors')
, app = express();

app.options('/products/:id', cors.preflight()); // enable preflight request
app.options('/products/:id', cors()); // enable preflight request
app.get('/products/:id', cors(), function(req, res, next){
res.json({msg: 'This is CORS-enabled for all origins!'});
});
Expand All @@ -49,7 +49,7 @@ var corsOptions = {
origin: 'http://example.com'
};

app.options('/products/:id', cors.preflight(corsOptions)); // enable preflight request
app.options('/products/:id', cors(corsOptions)); // enable preflight request
app.get('/products/:id', cors(corsOptions), function(req, res, next){
res.json({msg: 'This is CORS-enabled for only example.com.'});
});
Expand Down Expand Up @@ -77,7 +77,7 @@ var corsOptionsDelegate = function(req, callback){
callback(null, corsOptions); // callback expects two parameters: error and options
};

app.options('/products/:id', cors.preflight(corsOptionsDelegate)); // enable preflight request
app.options('/products/:id', cors(corsOptionsDelegate)); // enable preflight request
app.get('/products/:id', cors(corsOptionsDelegate), function(req, res, next){
res.json({msg: 'This is CORS-enabled for a whitelisted domain.'});
});
Expand Down
10 changes: 0 additions & 10 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,3 @@ module.exports = function(param){
delegate(req, handleDelegateResponse);
};
};

module.exports.preflight = function(param){
return function(req, res, next){
if(req.method === 'OPTIONS'){
module.exports(param)(req, res, next);
}else{
next();
}
};
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cors"
, "version": "0.1.0"
, "version": "0.1.1"
, "author": "Troy Goode <troygoode@gmail.com> (https://github.com/troygoode/)"
, "description": "middleware for dynamically or statically enabling CORS in express/connect applications"
, "keywords": ["cors", "express", "connect", "middleware"]
Expand Down
2 changes: 1 addition & 1 deletion test/example-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ simpleApp.post('/', cors(), function(req, res){
/* -------------------------------------------------------------------------- */

var complexApp = express();
complexApp.options('/', cors.preflight());
complexApp.options('/', cors());
complexApp.del('/', cors(), function(req, res){
res.send('Hello World (Delete)');
});
Expand Down
2 changes: 1 addition & 1 deletion test/issue-2.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var app = express(),
credentials: true,
maxAge: 3600
};
app.options('/api/login', cors.preflight(corsOptions));
app.options('/api/login', cors(corsOptions));
app.post('/api/login', cors(corsOptions), function(req, res){
res.send('LOGIN');
});
Expand Down

0 comments on commit dec52de

Please sign in to comment.