forked from bigearth/rest.bitbox.earth
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #460 from Bitcoin-com/stage
v3.11.2
- Loading branch information
Showing
12 changed files
with
124 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
"use strict"; | ||
/* | ||
This middleware logs connection information to local logs. It gives the ability | ||
to detect when the server is being DDOS attacked, and also to collect metrics, | ||
like the most popular endpoints. | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var wlogger = require("../util/winston-logging"); | ||
// Used for debugging and iterrogating JS objects. | ||
var util = require("util"); | ||
util.inspect.defaultOptions = { depth: 1 }; | ||
var logReqInfo = function (req, res, next) { | ||
/* | ||
//console.log(`req: ${util.inspect(req)}`) | ||
console.log(`req.headers: ${util.inspect(req.headers)}`) | ||
console.log(`req.url: ${req.url}`) | ||
console.log(`req.method: ${req.method}`) | ||
console.log(`req.sws.ip: ${req.sws.ip}`) | ||
console.log(`req.sws.real_ip: ${req.sws.real_ip}`) | ||
console.log(`req.body: ${util.inspect(req.body)}`) | ||
console.log(` `) | ||
console.log(` `) | ||
*/ | ||
var ip = req.sws.real_ip; | ||
var method = req.method; | ||
var url = req.url; | ||
var dataToLog = { | ||
headers: req.headers, | ||
url: url, | ||
method: method, | ||
ip: req.sws.ip, | ||
real_ip: ip, | ||
body: req.body | ||
}; | ||
wlogger.verbose("Request: " + ip + " " + method + " " + url, dataToLog); | ||
next(); | ||
}; | ||
exports.logReqInfo = logReqInfo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "rest.bitcoin.com", | ||
"version": "3.11.1", | ||
"version": "3.11.2", | ||
"description": "REST API for Bitcoin.com's Cloud", | ||
"author": "Gabriel Cardona <[email protected]>", | ||
"contributors": [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
This middleware logs connection information to local logs. It gives the ability | ||
to detect when the server is being DDOS attacked, and also to collect metrics, | ||
like the most popular endpoints. | ||
*/ | ||
|
||
import * as express from "express" | ||
const wlogger = require("../util/winston-logging") | ||
|
||
// Used for debugging and iterrogating JS objects. | ||
const util = require("util") | ||
util.inspect.defaultOptions = { depth: 1 } | ||
|
||
// Add the 'locals' property to the express.Request interface. | ||
declare global { | ||
namespace Express { | ||
interface Request { | ||
locals: any, | ||
sws: any | ||
} | ||
} | ||
} | ||
|
||
const logReqInfo = function( | ||
req: express.Request, | ||
res: express.Response, | ||
next: express.NextFunction | ||
) { | ||
|
||
/* | ||
//console.log(`req: ${util.inspect(req)}`) | ||
console.log(`req.headers: ${util.inspect(req.headers)}`) | ||
console.log(`req.url: ${req.url}`) | ||
console.log(`req.method: ${req.method}`) | ||
console.log(`req.sws.ip: ${req.sws.ip}`) | ||
console.log(`req.sws.real_ip: ${req.sws.real_ip}`) | ||
console.log(`req.body: ${util.inspect(req.body)}`) | ||
console.log(` `) | ||
console.log(` `) | ||
*/ | ||
const ip = req.sws.real_ip | ||
const method = req.method | ||
const url = req.url | ||
|
||
const dataToLog = { | ||
headers: req.headers, | ||
url: url, | ||
method: method, | ||
ip: req.sws.ip, | ||
real_ip: ip, | ||
body: req.body | ||
} | ||
|
||
wlogger.verbose(`Request: ${ip} ${method} ${url}`, dataToLog) | ||
|
||
next() | ||
} | ||
|
||
export { logReqInfo } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters