(jsrt) fix: elapsed time calc

This commit is contained in:
lollipopkit🏳️‍⚧️
2025-07-16 12:53:35 +08:00
parent 9a48ed47f4
commit 9d9070c899
4 changed files with 19 additions and 13 deletions

View File

@@ -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) {

View File

@@ -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');
}

View File

@@ -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);
}