Even More Debugging
All checks were successful
Publish to Private NPM Registry / publish (push) Successful in 46s
All checks were successful
Publish to Private NPM Registry / publish (push) Successful in 46s
This commit is contained in:
parent
62b91507d8
commit
e3ba1639c4
1 changed files with 11 additions and 4 deletions
|
|
@ -65,14 +65,15 @@ export function Page(title: string, page: string, extraScripts: (string | { scri
|
||||||
|
|
||||||
console.log('[Page Decorator] Original:', original);
|
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
|
// 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.
|
// An error handler starts with the error object, then the request, response and next functions.
|
||||||
if(original.length > 3) {
|
if(original.length > 3) {
|
||||||
descriptor.value = async function (err: Error, req: Request, res: Response, next: NextFunction, ...args: any[]) {
|
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 {
|
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
|
// 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);
|
doRender(propertyKey, output, err, req, res, next, ...args);
|
||||||
}
|
}
|
||||||
catch(error) {
|
catch(error) {
|
||||||
|
console.error('[Page Decorator] Error:', error);
|
||||||
next(error);
|
next(error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -103,6 +105,10 @@ export function Page(title: string, page: string, extraScripts: (string | { scri
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
descriptor.value = async function (req: Request, res: Response, next: NextFunction) {
|
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 {
|
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
|
// 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);*/
|
args.find(arg => isResponse(arg)).render('base', renderParams);*/
|
||||||
}
|
}
|
||||||
catch(error) {
|
catch(error) {
|
||||||
|
console.error('[Page Decorator] Error:', error);
|
||||||
next(error);
|
next(error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue