web/api: log requests to console
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
e8dc6b259f
commit
1b63e461cc
|
@ -2,11 +2,19 @@ import * as Sentry from "@sentry/browser";
|
||||||
import { Integrations } from "@sentry/tracing";
|
import { Integrations } from "@sentry/tracing";
|
||||||
import { VERSION } from "../constants";
|
import { VERSION } from "../constants";
|
||||||
import { SentryIgnoredError } from "../common/errors";
|
import { SentryIgnoredError } from "../common/errors";
|
||||||
import { Config, Configuration, RootApi } from "authentik-api";
|
import { Config, Configuration, Middleware, ResponseContext, RootApi } from "authentik-api";
|
||||||
import { getCookie } from "../utils";
|
import { getCookie } from "../utils";
|
||||||
import { API_DRAWER_MIDDLEWARE } from "../elements/notifications/APIDrawer";
|
import { API_DRAWER_MIDDLEWARE } from "../elements/notifications/APIDrawer";
|
||||||
import { MessageMiddleware } from "../elements/messages/Middleware";
|
import { MessageMiddleware } from "../elements/messages/Middleware";
|
||||||
|
|
||||||
|
export class LoggingMiddleware implements Middleware {
|
||||||
|
|
||||||
|
post(context: ResponseContext): Promise<Response | void> {
|
||||||
|
console.debug(`authentik/api: ${context.init.method} ${context.url} => ${context.response.status}`);
|
||||||
|
return Promise.resolve(context.response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const DEFAULT_CONFIG = new Configuration({
|
export const DEFAULT_CONFIG = new Configuration({
|
||||||
basePath: "/api/v2beta",
|
basePath: "/api/v2beta",
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -16,6 +24,7 @@ export const DEFAULT_CONFIG = new Configuration({
|
||||||
middleware: [
|
middleware: [
|
||||||
API_DRAWER_MIDDLEWARE,
|
API_DRAWER_MIDDLEWARE,
|
||||||
new MessageMiddleware(),
|
new MessageMiddleware(),
|
||||||
|
new LoggingMiddleware(),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Reference in a new issue