softkave-node-utils 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,2 @@
1
1
  export * from './error.js';
2
- export * from './getClientConfig.js';
3
- export * from './logger/index.js';
4
2
  //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,2 @@
1
1
  export * from './error.js';
2
- export * from './getClientConfig.js';
3
- export * from './logger/index.js';
4
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
@@ -0,0 +1,5 @@
1
+ export interface ILogger {
2
+ log(...args: unknown[]): void;
3
+ error(...args: unknown[]): void;
4
+ }
5
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/common/logger.ts"],"names":[],"mappings":""}
@@ -1,7 +1,10 @@
1
1
  import type { NextRequest } from 'next/server.js';
2
2
  import type { AnyFn } from 'softkave-js-utils';
3
+ import type { ILogger } from '../common/logger.js';
3
4
  export interface IRouteContext<T = unknown> {
4
5
  params: Promise<T>;
5
6
  }
6
- export declare const wrapRoute: <TRequest extends NextRequest>(routeFn: AnyFn) => (req: TRequest, ctx: IRouteContext) => Promise<Response>;
7
+ export declare const wrapRoute: <TRequest extends NextRequest>(routeFn: AnyFn, opts?: {
8
+ logger?: ILogger;
9
+ }) => (req: TRequest, ctx: IRouteContext) => Promise<Response>;
7
10
  //# sourceMappingURL=wrapRoute.d.ts.map
@@ -1,10 +1,9 @@
1
1
  import { AssertionError } from 'assert';
2
2
  import { ZodError } from 'zod';
3
3
  import { OwnError, OwnServerError } from '../common/error.js';
4
- import { fimidxConsoleLogger } from '../common/index.js';
5
- export const wrapRoute = (routeFn) => async (req, ctx) => {
4
+ export const wrapRoute = (routeFn, opts) => async (req, ctx) => {
6
5
  try {
7
- // fimidxConsoleLogger.info("Route called", {
6
+ // opts?.logger?.log("Route called", {
8
7
  // path: req.nextUrl.pathname,
9
8
  // method: req.method,
10
9
  // params: ctx.params,
@@ -16,7 +15,7 @@ export const wrapRoute = (routeFn) => async (req, ctx) => {
16
15
  });
17
16
  }
18
17
  catch (error) {
19
- fimidxConsoleLogger.error(error);
18
+ opts?.logger?.error(error);
20
19
  if (OwnServerError.isOwnServerError(error)) {
21
20
  return Response.json({ message: error.message, name: 'OwnServerError' }, { status: error.statusCode });
22
21
  }
@@ -1 +1 @@
1
- {"version":3,"file":"wrapRoute.js","sourceRoot":"","sources":["../../src/next/wrapRoute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,QAAQ,CAAC;AAGtC,OAAO,EAAC,QAAQ,EAAC,MAAM,KAAK,CAAC;AAC7B,OAAO,EAAC,QAAQ,EAAE,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAC,mBAAmB,EAAC,MAAM,oBAAoB,CAAC;AAMvD,MAAM,CAAC,MAAM,SAAS,GACpB,CAA+B,OAAc,EAAE,EAAE,CACjD,KAAK,EAAE,GAAa,EAAE,GAAkB,EAAE,EAAE;IAC1C,IAAI,CAAC;QACH,6CAA6C;QAC7C,gCAAgC;QAChC,wBAAwB;QACxB,wBAAwB;QACxB,MAAM;QACN,IAAI,MAAM,GAAG,MAAM,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACrC,MAAM,GAAG,MAAM,IAAI,EAAE,CAAC;QACtB,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE;YAC3B,MAAM,EAAE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AY,QAAQ,EAAE,CAAC;YACrC,MAAM,eAAe,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;YACvC,OAAO,QAAQ,CAAC,IAAI,CAClB,EAAC,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,UAAU,EAAC,EAC5C,EAAC,MAAM,EAAE,GAAG,EAAC,CACd,CAAC;QACJ,CAAC;aAAM,IAAI,KAAK,YAAY,cAAc,EAAE,CAAC;YAC3C,OAAO,QAAQ,CAAC,IAAI,CAClB,EAAC,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAC,EAChD,EAAC,MAAM,EAAE,GAAG,EAAC,CACd,CAAC;QACJ,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,CAClB,EAAC,OAAO,EAAE,uBAAuB,EAAE,IAAI,EAAE,cAAc,EAAC,EACxD,EAAC,MAAM,EAAE,GAAG,EAAC,CACd,CAAC;IACJ,CAAC;AACH,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "softkave-node-utils",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Softkave Node.js utilities",
5
5
  "author": {
6
6
  "email": "ywordk@gmail.com",
@@ -62,7 +62,6 @@
62
62
  "peerDependencies": {
63
63
  "@types/lodash-es": "^4.17.12",
64
64
  "@types/node": "^20",
65
- "fimidx": "^0.7.0",
66
65
  "lodash-es": "^4.17.21",
67
66
  "next": "15.5.9",
68
67
  "softkave-js-utils": "^0.17.1",
@@ -1,7 +0,0 @@
1
- export declare const getClientConfig: () => {
2
- fimidxProjectId: string;
3
- fimidxClientToken: string;
4
- fimidxLoggerEnabled: boolean;
5
- fimidxServerUrl?: string | undefined;
6
- };
7
- //# sourceMappingURL=getClientConfig.d.ts.map
@@ -1,20 +0,0 @@
1
- import { z } from 'zod';
2
- const fimidxProjectId = process.env.NEXT_PUBLIC_FIMIDX_LOGGER_PROJECT_ID;
3
- const fimidxClientToken = process.env.NEXT_PUBLIC_FIMIDX_LOGGER_CLIENT_TOKEN;
4
- const fimidxLoggerEnabled = process.env.NEXT_PUBLIC_FIMIDX_LOGGER_ENABLED;
5
- const fimidxServerUrl = process.env.NEXT_PUBLIC_FIMIDX_LOGGER_SERVER_URL;
6
- const clientConfigSchema = z.object({
7
- fimidxProjectId: z.string(),
8
- fimidxClientToken: z.string(),
9
- fimidxLoggerEnabled: z.boolean().default(false),
10
- fimidxServerUrl: z.string().url().optional(),
11
- });
12
- export const getClientConfig = () => {
13
- return clientConfigSchema.parse({
14
- fimidxProjectId,
15
- fimidxClientToken,
16
- fimidxLoggerEnabled: fimidxLoggerEnabled === 'true',
17
- fimidxServerUrl,
18
- });
19
- };
20
- //# sourceMappingURL=getClientConfig.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getClientConfig.js","sourceRoot":"","sources":["../../src/common/getClientConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC;AACzE,MAAM,iBAAiB,GAAG,OAAO,CAAC,GAAG,CAAC,sCAAsC,CAAC;AAC7E,MAAM,mBAAmB,GAAG,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC;AAC1E,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC;AAEzE,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE;IAC3B,iBAAiB,EAAE,CAAC,CAAC,MAAM,EAAE;IAC7B,mBAAmB,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;IAC/C,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;CAC7C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE;IAClC,OAAO,kBAAkB,CAAC,KAAK,CAAC;QAC9B,eAAe;QACf,iBAAiB;QACjB,mBAAmB,EAAE,mBAAmB,KAAK,MAAM;QACnD,eAAe;KAChB,CAAC,CAAC;AACL,CAAC,CAAC"}
@@ -1,3 +0,0 @@
1
- import { FimidxNextAuthLogger } from 'fimidx';
2
- export declare const fimidxNextAuthLogger: FimidxNextAuthLogger;
3
- //# sourceMappingURL=fimidx-auth-logger.d.ts.map
@@ -1,7 +0,0 @@
1
- import { FimidxNextAuthLogger } from 'fimidx';
2
- import { fimidxConsoleLogger } from './fimidx-console-logger.js';
3
- export const fimidxNextAuthLogger = new FimidxNextAuthLogger({
4
- fimidxConsoleLogger,
5
- debug: false,
6
- });
7
- //# sourceMappingURL=fimidx-auth-logger.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fimidx-auth-logger.js","sourceRoot":"","sources":["../../../src/common/logger/fimidx-auth-logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,QAAQ,CAAC;AAC5C,OAAO,EAAC,mBAAmB,EAAC,MAAM,4BAA4B,CAAC;AAE/D,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,oBAAoB,CAAC;IAC3D,mBAAmB;IACnB,KAAK,EAAE,KAAK;CACb,CAAC,CAAC"}
@@ -1,3 +0,0 @@
1
- import { FimidxConsoleLikeLogger } from 'fimidx';
2
- export declare const fimidxConsoleLogger: FimidxConsoleLikeLogger;
3
- //# sourceMappingURL=fimidx-console-logger.d.ts.map
@@ -1,10 +0,0 @@
1
- import { FimidxConsoleLikeLogger } from 'fimidx';
2
- import { getClientConfig } from '../getClientConfig.js';
3
- import { fimidxLogger } from './fimidx-logger.js';
4
- const { fimidxLoggerEnabled } = getClientConfig();
5
- export const fimidxConsoleLogger = new FimidxConsoleLikeLogger({
6
- fimidxLogger: fimidxLogger,
7
- enableConsoleFallback: true,
8
- logToFimidx: fimidxLoggerEnabled,
9
- });
10
- //# sourceMappingURL=fimidx-console-logger.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fimidx-console-logger.js","sourceRoot":"","sources":["../../../src/common/logger/fimidx-console-logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,uBAAuB,EAAC,MAAM,QAAQ,CAAC;AAC/C,OAAO,EAAC,eAAe,EAAC,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAEhD,MAAM,EAAC,mBAAmB,EAAC,GAAG,eAAe,EAAE,CAAC;AAEhD,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,uBAAuB,CAAC;IAC7D,YAAY,EAAE,YAAY;IAC1B,qBAAqB,EAAE,IAAI;IAC3B,WAAW,EAAE,mBAAmB;CACjC,CAAC,CAAC"}
@@ -1,3 +0,0 @@
1
- import { FimidxLogger } from 'fimidx';
2
- export declare const fimidxLogger: FimidxLogger;
3
- //# sourceMappingURL=fimidx-logger.d.ts.map
@@ -1,11 +0,0 @@
1
- import { FimidxLogger } from 'fimidx';
2
- import { getClientConfig } from '../getClientConfig.js';
3
- const { fimidxProjectId, fimidxClientToken, fimidxServerUrl } = getClientConfig();
4
- export const fimidxLogger = new FimidxLogger({
5
- projectId: fimidxProjectId,
6
- clientToken: fimidxClientToken,
7
- consoleLogOnError: true,
8
- logRemoteErrors: true,
9
- ...(fimidxServerUrl ? { serverURL: fimidxServerUrl } : {}),
10
- });
11
- //# sourceMappingURL=fimidx-logger.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fimidx-logger.js","sourceRoot":"","sources":["../../../src/common/logger/fimidx-logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAC,eAAe,EAAC,MAAM,uBAAuB,CAAC;AAEtD,MAAM,EAAC,eAAe,EAAE,iBAAiB,EAAE,eAAe,EAAC,GAAG,eAAe,EAAE,CAAC;AAEhF,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,YAAY,CAAC;IAC3C,SAAS,EAAE,eAAe;IAC1B,WAAW,EAAE,iBAAiB;IAC9B,iBAAiB,EAAE,IAAI;IACvB,eAAe,EAAE,IAAI;IACrB,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,EAAC,SAAS,EAAE,eAAe,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC;CACzD,CAAC,CAAC"}
@@ -1,4 +0,0 @@
1
- export * from './fimidx-auth-logger.js';
2
- export * from './fimidx-console-logger.js';
3
- export * from './fimidx-logger.js';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1,4 +0,0 @@
1
- export * from './fimidx-auth-logger.js';
2
- export * from './fimidx-console-logger.js';
3
- export * from './fimidx-logger.js';
4
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/logger/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC"}