mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-04-14 19:56:23 +00:00
Merge branch 'release' into sabrecat/postfixes
This commit is contained in:
commit
c50ed843fb
3 changed files with 24 additions and 17 deletions
4
package-lock.json
generated
4
package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "habitica",
|
||||
"version": "5.25.7",
|
||||
"version": "5.25.8",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "habitica",
|
||||
"version": "5.25.7",
|
||||
"version": "5.25.8",
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.22.10",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "habitica",
|
||||
"description": "A habit tracker app which treats your goals like a Role Playing Game.",
|
||||
"version": "5.25.7",
|
||||
"version": "5.25.8",
|
||||
"main": "./website/server/index.js",
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.22.10",
|
||||
|
|
|
|||
|
|
@ -1,28 +1,35 @@
|
|||
import { v4 as uuid } from 'uuid';
|
||||
import omit from 'lodash/omit';
|
||||
import logger from '../libs/logger';
|
||||
|
||||
function buildBaseLogData (req) {
|
||||
return {
|
||||
requestId: req.requestIdentifier,
|
||||
method: req.method,
|
||||
url: req.originalUrl,
|
||||
|
||||
headers: omit(req.headers, ['x-api-key', 'cookie', 'password', 'confirmPassword']),
|
||||
body: omit(req.body, ['password', 'confirmPassword']),
|
||||
query: omit(req.query, ['password', 'confirmPassword']),
|
||||
};
|
||||
}
|
||||
|
||||
export const logRequestEnd = (req, res) => {
|
||||
const now = Date.now();
|
||||
const requestTime = now - req.requestStartTime;
|
||||
logger.info('Request completed', {
|
||||
requestId: req.requestIdentifier,
|
||||
method: req.method,
|
||||
url: req.originalUrl,
|
||||
duration: requestTime,
|
||||
endTime: now,
|
||||
statusCode: res.statusCode,
|
||||
});
|
||||
const data = buildBaseLogData(req);
|
||||
data.duration = requestTime;
|
||||
data.endTime = now;
|
||||
data.statusCode = res.statusCode;
|
||||
logger.info('Request completed', data);
|
||||
};
|
||||
|
||||
export const logRequestData = (req, res, next) => {
|
||||
req.requestStartTime = Date.now();
|
||||
req.requestIdentifier = uuid();
|
||||
logger.info('Request started', {
|
||||
requestId: req.requestIdentifier,
|
||||
method: req.method,
|
||||
url: req.originalUrl,
|
||||
startTime: req.requestStartTime,
|
||||
});
|
||||
const data = buildBaseLogData(req);
|
||||
data.startTime = req.requestStartTime;
|
||||
logger.info('Request started', data);
|
||||
req.on('close', () => {
|
||||
logRequestEnd(req, res);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue