From 027b23911426578aedfa986feb669e7f82cf153b Mon Sep 17 00:00:00 2001 From: Krzysztof Wolski Date: Mon, 5 Sep 2022 11:09:06 +0200 Subject: [PATCH] Use APL debug util --- docs/debugging.md | 1 + src/APL/apl-debug.ts | 3 +++ src/APL/file-apl.ts | 4 ++-- src/APL/vercel-apl.ts | 4 ++-- src/middleware/middleware-debug.ts | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 src/APL/apl-debug.ts diff --git a/docs/debugging.md b/docs/debugging.md index cd8c5f8..3df6273 100644 --- a/docs/debugging.md +++ b/docs/debugging.md @@ -50,3 +50,4 @@ Use the namespace name to enable debug logs for each module. | \app-sdk:\* | Enable all | | app-sdk:AppBridge | Enable [AppBridge](./app-bridge.md) (browser only) | | app-sdk:Middleware:\* | Enable all middlewares (node only) | +| app-sdk:APL:\* | Enable all APLs (node only) | diff --git a/src/APL/apl-debug.ts b/src/APL/apl-debug.ts new file mode 100644 index 0000000..e25b627 --- /dev/null +++ b/src/APL/apl-debug.ts @@ -0,0 +1,3 @@ +import { createDebug } from "../debug"; + +export const createAPLDebug = (namespace: string) => createDebug(`APL:${namespace}`); diff --git a/src/APL/file-apl.ts b/src/APL/file-apl.ts index a1653d7..4f52b9e 100644 --- a/src/APL/file-apl.ts +++ b/src/APL/file-apl.ts @@ -1,9 +1,9 @@ -import debugPkg from "debug"; import { promises as fsPromises } from "fs"; import { APL, AuthData } from "./apl"; +import { createAPLDebug } from "./apl-debug"; -const debug = debugPkg.debug("app-sdk:FileAPL"); +const debug = createAPLDebug("FileAPL"); export type FileAPLConfig = { fileName?: string; diff --git a/src/APL/vercel-apl.ts b/src/APL/vercel-apl.ts index 6595182..a529e25 100644 --- a/src/APL/vercel-apl.ts +++ b/src/APL/vercel-apl.ts @@ -1,10 +1,10 @@ /* eslint-disable class-methods-use-this */ -import debugPkg from "debug"; import fetch from "node-fetch"; import { APL, AuthData } from "./apl"; +import { createAPLDebug } from "./apl-debug"; -const debug = debugPkg.debug("app-sdk:VercelAPL"); +const debug = createAPLDebug("VercelAPL"); export const VercelAPLVariables = { TOKEN_VARIABLE_NAME: "SALEOR_AUTH_TOKEN", diff --git a/src/middleware/middleware-debug.ts b/src/middleware/middleware-debug.ts index 239954b..a44ea0e 100644 --- a/src/middleware/middleware-debug.ts +++ b/src/middleware/middleware-debug.ts @@ -5,7 +5,7 @@ import { createDebug } from "../debug"; export const createMiddlewareDebug = (middleware: string) => createDebug(`Middleware:${middleware}`); -type DebugFactory = (handlerName: string) => (msg: string, ...args: any[]) => void; +type DebugFactory = (handlerName: string) => (msg: string, ...args: unknown[]) => void; /** * Experimental. Needs to be tested and evaluated on security