softkave-node-utils 0.5.2 → 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.
- package/build/common/index.d.ts +0 -2
- package/build/common/index.js +0 -2
- package/build/common/index.js.map +1 -1
- package/build/common/logger.d.ts +5 -0
- package/build/common/logger.js +2 -0
- package/build/common/logger.js.map +1 -0
- package/build/next/wrapRoute.d.ts +4 -1
- package/build/next/wrapRoute.js +3 -4
- package/build/next/wrapRoute.js.map +1 -1
- package/package.json +3 -4
- package/build/common/getClientConfig.d.ts +0 -9
- package/build/common/getClientConfig.js +0 -23
- package/build/common/getClientConfig.js.map +0 -1
- package/build/common/logger/fimidx-auth-logger.d.ts +0 -3
- package/build/common/logger/fimidx-auth-logger.js +0 -7
- package/build/common/logger/fimidx-auth-logger.js.map +0 -1
- package/build/common/logger/fimidx-console-logger.d.ts +0 -3
- package/build/common/logger/fimidx-console-logger.js +0 -11
- package/build/common/logger/fimidx-console-logger.js.map +0 -1
- package/build/common/logger/fimidx-logger.d.ts +0 -3
- package/build/common/logger/fimidx-logger.js +0 -10
- package/build/common/logger/fimidx-logger.js.map +0 -1
- package/build/common/logger/index.d.ts +0 -4
- package/build/common/logger/index.js +0 -4
- package/build/common/logger/index.js.map +0 -1
package/build/common/index.d.ts
CHANGED
package/build/common/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
|
|
@@ -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
|
|
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
|
package/build/next/wrapRoute.js
CHANGED
|
@@ -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
|
-
|
|
5
|
-
export const wrapRoute = (routeFn) => async (req, ctx) => {
|
|
4
|
+
export const wrapRoute = (routeFn, opts) => async (req, ctx) => {
|
|
6
5
|
try {
|
|
7
|
-
//
|
|
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
|
-
|
|
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;AAC7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,EAAC,EAC1C,EAAC,MAAM,EAAE,GAAG,EAAC,CACd,CAAC;QACJ,CAAC;aAAM,IAAI,KAAK,YAAY,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.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Softkave Node.js utilities",
|
|
5
5
|
"author": {
|
|
6
6
|
"email": "ywordk@gmail.com",
|
|
@@ -62,12 +62,11 @@
|
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"@types/lodash-es": "^4.17.12",
|
|
64
64
|
"@types/node": "^20",
|
|
65
|
-
"fimidx": "^0.5.0",
|
|
66
65
|
"lodash-es": "^4.17.21",
|
|
67
|
-
"next": "15.
|
|
66
|
+
"next": "15.5.9",
|
|
68
67
|
"softkave-js-utils": "^0.17.1",
|
|
69
68
|
"zod": "^4.1.11",
|
|
70
|
-
"mongoose": "^
|
|
69
|
+
"mongoose": "^9.1.6",
|
|
71
70
|
"jsonwebtoken": "^9.0.2",
|
|
72
71
|
"typescript": "^5.9.3",
|
|
73
72
|
"@types/jsonwebtoken": "^9.0.10"
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare const getClientConfig: () => {
|
|
2
|
-
publicURL: string | undefined;
|
|
3
|
-
fimidxAppId: string;
|
|
4
|
-
fimidxClientToken: string;
|
|
5
|
-
fimidxServerUrl: string | undefined;
|
|
6
|
-
nodeEnv: string;
|
|
7
|
-
fimidxLoggerEnabled: boolean;
|
|
8
|
-
};
|
|
9
|
-
//# sourceMappingURL=getClientConfig.d.ts.map
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import assert from 'assert';
|
|
2
|
-
export const getClientConfig = () => {
|
|
3
|
-
const publicURL = process.env.NEXT_PUBLIC_URL;
|
|
4
|
-
const fimidxAppId = process.env.NEXT_PUBLIC_FIMIDX_LOGGER_APP_ID;
|
|
5
|
-
const fimidxClientToken = process.env.NEXT_PUBLIC_FIMIDX_LOGGER_CLIENT_TOKEN;
|
|
6
|
-
const fimidxServerUrl = process.env.NEXT_PUBLIC_FIMIDX_LOGGER_SERVER_URL;
|
|
7
|
-
const nodeEnv = process.env.NEXT_PUBLIC_APP_ENV;
|
|
8
|
-
const fimidxLoggerEnabled = process.env.NEXT_PUBLIC_FIMIDX_LOGGER_ENABLED === 'true';
|
|
9
|
-
// assert.ok(publicURL, 'NEXT_PUBLIC_URL is not set');
|
|
10
|
-
assert.ok(fimidxAppId, 'NEXT_PUBLIC_FIMIDX_LOGGER_APP_ID is not set');
|
|
11
|
-
assert.ok(fimidxClientToken, 'NEXT_PUBLIC_FIMIDX_LOGGER_CLIENT_TOKEN is not set');
|
|
12
|
-
// assert.ok(fimidxServerUrl, "NEXT_PUBLIC_FIMIDX_LOGGER_SERVER_URL is not set");
|
|
13
|
-
assert.ok(nodeEnv, 'NEXT_PUBLIC_APP_ENV is not set');
|
|
14
|
-
return {
|
|
15
|
-
publicURL,
|
|
16
|
-
fimidxAppId,
|
|
17
|
-
fimidxClientToken,
|
|
18
|
-
fimidxServerUrl,
|
|
19
|
-
nodeEnv,
|
|
20
|
-
fimidxLoggerEnabled,
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
//# sourceMappingURL=getClientConfig.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getClientConfig.js","sourceRoot":"","sources":["../../src/common/getClientConfig.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE;IAClC,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;IAC9C,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC;IACjE,MAAM,iBAAiB,GAAG,OAAO,CAAC,GAAG,CAAC,sCAAsC,CAAC;IAC7E,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC;IACzE,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;IAChD,MAAM,mBAAmB,GACvB,OAAO,CAAC,GAAG,CAAC,iCAAiC,KAAK,MAAM,CAAC;IAE3D,sDAAsD;IACtD,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,6CAA6C,CAAC,CAAC;IACtE,MAAM,CAAC,EAAE,CACP,iBAAiB,EACjB,mDAAmD,CACpD,CAAC;IACF,iFAAiF;IACjF,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,gCAAgC,CAAC,CAAC;IAErD,OAAO;QACL,SAAS;QACT,WAAW;QACX,iBAAiB;QACjB,eAAe;QACf,OAAO;QACP,mBAAmB;KACpB,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -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,11 +0,0 @@
|
|
|
1
|
-
import { FimidxConsoleLikeLogger } from 'fimidx';
|
|
2
|
-
import { getClientConfig } from '../getClientConfig.js';
|
|
3
|
-
import { fimidxLogger } from './fimidx-logger.js';
|
|
4
|
-
const { nodeEnv, fimidxLoggerEnabled } = getClientConfig();
|
|
5
|
-
export const fimidxConsoleLogger = new FimidxConsoleLikeLogger({
|
|
6
|
-
fimidxLogger: fimidxLogger,
|
|
7
|
-
// Enable console fallback in development
|
|
8
|
-
enableConsoleFallback: nodeEnv === 'development',
|
|
9
|
-
enabled: fimidxLoggerEnabled,
|
|
10
|
-
});
|
|
11
|
-
//# 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,OAAO,EAAE,mBAAmB,EAAC,GAAG,eAAe,EAAE,CAAC;AAEzD,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,uBAAuB,CAAC;IAC7D,YAAY,EAAE,YAAY;IAC1B,yCAAyC;IACzC,qBAAqB,EAAE,OAAO,KAAK,aAAa;IAChD,OAAO,EAAE,mBAAmB;CAC7B,CAAC,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { FimidxLogger } from 'fimidx';
|
|
2
|
-
import { getClientConfig } from '../getClientConfig.js';
|
|
3
|
-
const { fimidxAppId, fimidxClientToken } = getClientConfig();
|
|
4
|
-
export const fimidxLogger = new FimidxLogger({
|
|
5
|
-
appId: fimidxAppId,
|
|
6
|
-
clientToken: fimidxClientToken,
|
|
7
|
-
consoleLogOnError: true,
|
|
8
|
-
logRemoteErrors: true,
|
|
9
|
-
});
|
|
10
|
-
//# 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,WAAW,EAAE,iBAAiB,EAAC,GAAG,eAAe,EAAE,CAAC;AAE3D,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,YAAY,CAAC;IAC3C,KAAK,EAAE,WAAW;IAClB,WAAW,EAAE,iBAAiB;IAC9B,iBAAiB,EAAE,IAAI;IACvB,eAAe,EAAE,IAAI;CACtB,CAAC,CAAC"}
|
|
@@ -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"}
|