mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-04-30 18:01:47 +00:00
(jsrt) fix: elapsed time calc
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
// Utility functions for JavaScript runtime
|
||||
|
||||
function logWithTimestamp(message) {
|
||||
const timestamp = new Date().toISOString();
|
||||
console.log(`[${timestamp}] ${message}`);
|
||||
function logWithReq(message) {
|
||||
let reqPath = req.url || 'unknown path';
|
||||
console.log(`[${req.method} ${reqPath}] ${message}`);
|
||||
}
|
||||
|
||||
function safeJsonParse(str, defaultValue = null) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Pre-processing function for incoming requests
|
||||
|
||||
function preProcessRequest(req) {
|
||||
logWithTimestamp('Pre-processing request: ' + req.method + ' ' + req.url);
|
||||
function preProcessRequest() {
|
||||
logWithReq('Pre-processing request');
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Post-processing function for outgoing responses
|
||||
|
||||
function postProcessResponse(req, res) {
|
||||
logWithTimestamp('Post-processing response with status: ' + res.statusCode);
|
||||
function postProcessResponse() {
|
||||
logWithReq('Post-processing response with status: ' + req.statusCode);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user