add middleware writeLog

This commit is contained in:
joseph le 2023-09-29 11:19:36 +07:00
parent bc19538431
commit fe6ef901b8
1 changed files with 8 additions and 4 deletions

View File

@ -24,7 +24,7 @@ const shortenStringsInObject = (obj, maxLength) => {
// Rút ngắn chuỗi lại maxLength ký tự
obj = "[Array:"+obj.length+"]\n"+obj.slice(0,15)
}
return obj;
}
@ -44,11 +44,15 @@ export function loggerAPI(request, response, location) {
response.getStatus() +
" - " +
location +
"\n------------PAYLOAD-----------\n" +
"\n------PAYLOAD------\n" +
JSON.stringify(request.all()) +
"\n--------------DATA-------------\n" +
"\n-------DATA--------\n" +
JSON.stringify(body) +
"\n-------------------------------";
"\n-------HEADERS--------\n" +
JSON.stringify(request.headers()) +
"\n-------PARAMS--------\n" +
JSON.stringify(request.params()) +
"\n\n======================================================================\n======================================================================";
fs.exists(fileName, async (exists) => {
if (exists) {