Skip to content

Commit

Permalink
Poehali!
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladimir Varankin committed Dec 14, 2014
0 parents commit 716b6fc
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/node_modules
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2013 Yandex LLC

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
27 changes: 27 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
var domain = require('domain'),
d = domain.create(),
requestId = module.exports;

requestId.createMiddleware = function createRequestIdMiddleware() {
return function(req, res, next) {
d.run(function() {
requestId.set(req.headers['x-request-id']);
next();
});
}
};

requestId.get = function getRequestId() {
var activeDomain = domain.active;
if(activeDomain != null) {
return activeDomain.requestId;
}
};

requestId.set = function setRequestId(id) {
var activeDomain = domain.active;
if(activeDomain != null && typeof activeDomain.requestId === 'undefined') {
activeDomain.requestId = id;
}
return activeDomain;
};
30 changes: 30 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "nodules-requestid",
"version": "0.1.0",
"description": "X-Request-Id signer for Node.js",
"scripts": {
"test": "make test"
},
"repository": {
"type": "git",
"url": "https://github.com/nodules/requestid.git"
},
"author": "Varankin Vladimir <[email protected]> (http://github.com/narqo)",
"maintainers": [
"Varankin Vladimir <[email protected]> (http://github.com/narqo)",
"Phillip Kovalev <[email protected]> (https://github.com/kaero)"
],
"bugs": {
"url": "https://github.com/nodules/requestid/issues"
},
"devDependencies": {
"chai": "^1.10.0",
"istanbul": "^0.3.5",
"jscs": "1.4.x",
"jshint": "~2.3.0",
"mocha": "^2.0.1"
},
"engine": {
"node": ">=0.10"
}
}

0 comments on commit 716b6fc

Please sign in to comment.