diff --git a/src/decorators/Page.ts b/src/decorators/Page.ts index 591e4c1..fc3a34b 100644 --- a/src/decorators/Page.ts +++ b/src/decorators/Page.ts @@ -65,14 +65,15 @@ export function Page(title: string, page: string, extraScripts: (string | { scri console.log('[Page Decorator] Original:', original); - if(original.length === 1 && typeof original[0] === 'function') { - console.log('[Page Decorator] Original First Parameter:', original[0]); - } - // If the original function has more than 3 parameters, we can assume it is an error handler // An error handler starts with the error object, then the request, response and next functions. if(original.length > 3) { descriptor.value = async function (err: Error, req: Request, res: Response, next: NextFunction, ...args: any[]) { + console.log('[Page Decorator] Error:', err); + console.log('[Page Decorator] Request:', req); + console.log('[Page Decorator] Response:', res); + console.log('[Page Decorator] Next:', next); + try { // We run the original here so that if the decorated method has specific checks it needs to make (ex. if the ID of whatever actually exists) it can make them before rendering the page // @@ -96,6 +97,7 @@ export function Page(title: string, page: string, extraScripts: (string | { scri doRender(propertyKey, output, err, req, res, next, ...args); } catch(error) { + console.error('[Page Decorator] Error:', error); next(error); return; } @@ -103,6 +105,10 @@ export function Page(title: string, page: string, extraScripts: (string | { scri } else { descriptor.value = async function (req: Request, res: Response, next: NextFunction) { + console.log('[Page Decorator] Request:', req); + console.log('[Page Decorator] Response:', res); + console.log('[Page Decorator] Next:', next); + try { // We run the original here so that if the decorated method has specific checks it needs to make (ex. if the ID of whatever actually exists) it can make them before rendering the page // @@ -143,6 +149,7 @@ export function Page(title: string, page: string, extraScripts: (string | { scri args.find(arg => isResponse(arg)).render('base', renderParams);*/ } catch(error) { + console.error('[Page Decorator] Error:', error); next(error); return; }