Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It would be cool to have a debug option that would print all the activity #158

Open
soswow opened this issue Aug 20, 2018 · 0 comments
Open
Assignees

Comments

@soswow
Copy link
Collaborator

soswow commented Aug 20, 2018

Currently as soon as route for defined all the requests are going through kakapo and do not appear in network panel of a dev tools, which is not ideal. Sometimes dev would like to know what requests are happening and what responses were issued.

Current workaround for me is to make subclass of a router and do logging manually:

class RouterWithLogging<M extends DatabaseSchema> extends Router<M> {

  constructor(options?: RouterOptions){
    super(options);
  }

  register(method: string, path: string, originalHandler: RequestHandler<M>) {
    const handler: RequestHandler<M> = (
      request: Request,
      database: Database<M>
    ) => {
      const response = originalHandler(request, database);
      console.log({method, path, request, database, response});
      return response;
    };
    return super.register(method, path, handler);
  }
}
@zzarcon zzarcon assigned zzarcon and soswow and unassigned zzarcon Aug 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants