@kuckit/api 1.0.3 → 2.0.1
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/dist/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","names":[],"sources":["../src/context.ts"],"sourcesContent":[],"mappings":";;;;;;IAGsD,UAAA,OAAA,CAAA;MAAA,KAAA,CAAA,EAM3C,eAN2C;IAM3C;EAAe;;AAKT,UAAA,oBAAA,CACX;EAOgB,GAAA,EAPhB,OAOgB;;;;;
|
|
1
|
+
{"version":3,"file":"context.d.ts","names":[],"sources":["../src/context.ts"],"sourcesContent":[],"mappings":";;;;;;IAGsD,UAAA,OAAA,CAAA;MAAA,KAAA,CAAA,EAM3C,eAN2C;IAM3C;EAAe;;AAKT,UAAA,oBAAA,CACX;EAOgB,GAAA,EAPhB,OAOgB;;;;;AAmDtB;AAAgD,iBAnD1B,aAAA,CAmD0B,IAAA,EAnDN,oBAmDM,CAAA,EAnDc,OAmDd,CAAA;EAAlB,OAAA,EAAA,GAAA;EAAR,EAAA,iBAAA,CAAA,GAAA,CAAA;CAAO,CAAA;KAAjB,OAAA,GAAU,QAAQ,kBAAkB"}
|
package/dist/context.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { fromNodeHeaders } from "better-auth/node";
|
|
2
|
-
import { auth } from "@kuckit/auth";
|
|
3
2
|
import { asValue } from "awilix";
|
|
4
3
|
|
|
5
4
|
//#region src/context.ts
|
|
@@ -8,8 +7,10 @@ import { asValue } from "awilix";
|
|
|
8
7
|
* Injects logger with requestId for structured tracing
|
|
9
8
|
*/
|
|
10
9
|
async function createContext(opts) {
|
|
10
|
+
const auth = opts.req.scope?.cradle.auth;
|
|
11
11
|
let session;
|
|
12
12
|
try {
|
|
13
|
+
if (!auth) throw new Error("Auth not available in request scope");
|
|
13
14
|
session = await auth.api.getSession({ headers: fromNodeHeaders(opts.req.headers) });
|
|
14
15
|
} catch (error) {
|
|
15
16
|
console.error("[Auth] Failed to get session:", error, "Headers:", opts.req.headers);
|
package/dist/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","names":[],"sources":["../src/context.ts"],"sourcesContent":["import type { Request } from 'express'\nimport { fromNodeHeaders } from 'better-auth/node'\nimport {
|
|
1
|
+
{"version":3,"file":"context.js","names":[],"sources":["../src/context.ts"],"sourcesContent":["import type { Request } from 'express'\nimport { fromNodeHeaders } from 'better-auth/node'\nimport type { Auth } from '@kuckit/auth'\nimport { asValue, type AwilixContainer } from 'awilix'\n\ndeclare global {\n\t// eslint-disable-next-line @typescript-eslint/no-namespace\n\tnamespace Express {\n\t\tinterface Request {\n\t\t\tscope?: AwilixContainer\n\t\t}\n\t}\n}\n\nexport interface CreateContextOptions {\n\treq: Request\n}\n\n/**\n * Create per-request context with DI container\n * Injects logger with requestId for structured tracing\n */\nexport async function createContext(opts: CreateContextOptions) {\n\tconst auth = opts.req.scope?.cradle.auth as Auth | undefined\n\n\tlet session\n\ttry {\n\t\tif (!auth) {\n\t\t\tthrow new Error('Auth not available in request scope')\n\t\t}\n\t\tsession = await auth.api.getSession({\n\t\t\theaders: fromNodeHeaders(opts.req.headers),\n\t\t})\n\t} catch (error) {\n\t\tconsole.error('[Auth] Failed to get session:', error, 'Headers:', opts.req.headers)\n\t\tsession = null\n\t}\n\n\tconst requestId = crypto.randomUUID()\n\n\tif (opts.req.scope) {\n\t\topts.req.scope.register({\n\t\t\tsession: asValue(session),\n\t\t\trequestId: asValue(requestId),\n\t\t})\n\t}\n\n\tconst logger = opts.req.scope?.cradle.logger\n\tif (logger) {\n\t\tlogger.info('request_start', {\n\t\t\trequestId,\n\t\t\tuserId: session?.user?.id,\n\t\t\tmethod: opts.req.method,\n\t\t\tpath: opts.req.path,\n\t\t})\n\t}\n\n\t// Log request end on response finish\n\topts.req.on('end', () => {\n\t\tif (logger) {\n\t\t\tlogger.info('request_end', {\n\t\t\t\trequestId,\n\t\t\t\tuserId: session?.user?.id,\n\t\t\t})\n\t\t}\n\t})\n\n\treturn {\n\t\tsession,\n\t\tdi: opts.req.scope!,\n\t}\n}\n\nexport type Context = Awaited<ReturnType<typeof createContext>>\n"],"mappings":";;;;;;;;AAsBA,eAAsB,cAAc,MAA4B;CAC/D,MAAM,OAAO,KAAK,IAAI,OAAO,OAAO;CAEpC,IAAI;AACJ,KAAI;AACH,MAAI,CAAC,KACJ,OAAM,IAAI,MAAM,sCAAsC;AAEvD,YAAU,MAAM,KAAK,IAAI,WAAW,EACnC,SAAS,gBAAgB,KAAK,IAAI,QAAQ,EAC1C,CAAC;UACM,OAAO;AACf,UAAQ,MAAM,iCAAiC,OAAO,YAAY,KAAK,IAAI,QAAQ;AACnF,YAAU;;CAGX,MAAM,YAAY,OAAO,YAAY;AAErC,KAAI,KAAK,IAAI,MACZ,MAAK,IAAI,MAAM,SAAS;EACvB,SAAS,QAAQ,QAAQ;EACzB,WAAW,QAAQ,UAAU;EAC7B,CAAC;CAGH,MAAM,SAAS,KAAK,IAAI,OAAO,OAAO;AACtC,KAAI,OACH,QAAO,KAAK,iBAAiB;EAC5B;EACA,QAAQ,SAAS,MAAM;EACvB,QAAQ,KAAK,IAAI;EACjB,MAAM,KAAK,IAAI;EACf,CAAC;AAIH,MAAK,IAAI,GAAG,aAAa;AACxB,MAAI,OACH,QAAO,KAAK,eAAe;GAC1B;GACA,QAAQ,SAAS,MAAM;GACvB,CAAC;GAEF;AAEF,QAAO;EACN;EACA,IAAI,KAAK,IAAI;EACb"}
|
package/dist/routers/index.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import * as awilix7 from "awilix";
|
|
2
2
|
import * as _orpc_server10 from "@orpc/server";
|
|
3
3
|
import { RouterClient } from "@orpc/server";
|
|
4
|
-
import * as zod0 from "zod";
|
|
5
|
-
import * as zod_v4_core0 from "zod/v4/core";
|
|
6
4
|
|
|
7
5
|
//#region src/routers/index.d.ts
|
|
8
6
|
declare const appRouter: {
|
|
@@ -49,14 +47,7 @@ declare const appRouter: {
|
|
|
49
47
|
di: awilix7.AwilixContainer<any>;
|
|
50
48
|
}, {
|
|
51
49
|
session: any;
|
|
52
|
-
}>, _orpc_server10.Schema<unknown, unknown>,
|
|
53
|
-
id: zod0.ZodString;
|
|
54
|
-
name: zod0.ZodString;
|
|
55
|
-
email: zod0.ZodString;
|
|
56
|
-
emailVerified: zod0.ZodBoolean;
|
|
57
|
-
createdAt: zod0.ZodString;
|
|
58
|
-
updatedAt: zod0.ZodString;
|
|
59
|
-
}, zod_v4_core0.$strip>, Record<never, never>, Record<never, never>>;
|
|
50
|
+
}>, _orpc_server10.Schema<unknown, unknown>, any, Record<never, never>, Record<never, never>>;
|
|
60
51
|
};
|
|
61
52
|
};
|
|
62
53
|
type AppRouter = typeof appRouter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/routers/index.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/routers/index.ts"],"sourcesContent":[],"mappings":";;;;;cAIa;;;QAWZ,OAAA,CAAA;EAXY,CAAA,SAAA,CAAA,KAWZ,EAAA,KAAA,CAAA,EAAA;IAAA,OAAA,EAAA,GAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IACW,CAAA,CAAA,qCAA4B,CAAA;MAC5B,OAAA,EAAA,GAAe;;;;;;;KADf,SAAA,UAAmB;KACnB,eAAA,GAAkB,oBAAoB"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import * as awilix17 from "awilix";
|
|
2
2
|
import * as _orpc_server22 from "@orpc/server";
|
|
3
|
-
import * as zod6 from "zod";
|
|
4
|
-
import * as zod_v4_core0 from "zod/v4/core";
|
|
5
3
|
|
|
6
4
|
//#region src/routers/profile.d.ts
|
|
7
5
|
declare const profileRouter: {
|
|
@@ -22,14 +20,7 @@ declare const profileRouter: {
|
|
|
22
20
|
di: awilix17.AwilixContainer<any>;
|
|
23
21
|
}, {
|
|
24
22
|
session: any;
|
|
25
|
-
}>, _orpc_server22.Schema<unknown, unknown>,
|
|
26
|
-
id: zod6.ZodString;
|
|
27
|
-
name: zod6.ZodString;
|
|
28
|
-
email: zod6.ZodString;
|
|
29
|
-
emailVerified: zod6.ZodBoolean;
|
|
30
|
-
createdAt: zod6.ZodString;
|
|
31
|
-
updatedAt: zod6.ZodString;
|
|
32
|
-
}, zod_v4_core0.$strip>, Record<never, never>, Record<never, never>>;
|
|
23
|
+
}>, _orpc_server22.Schema<unknown, unknown>, any, Record<never, never>, Record<never, never>>;
|
|
33
24
|
};
|
|
34
25
|
//#endregion
|
|
35
26
|
export { profileRouter };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile.d.ts","names":[],"sources":["../../src/routers/profile.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"profile.d.ts","names":[],"sources":["../../src/routers/profile.ts"],"sourcesContent":[],"mappings":";;;;cAGa;;;;EAAA,EAAA,mCAaZ,oCAAA,CAAA;IAAA,OAAA,EAAA,GAAA;QAAA,QAAA,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kuckit/api",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"dotenv": "^17.2.2",
|
|
41
41
|
"zod": "^4.1.11",
|
|
42
42
|
"awilix": "^12.0.5",
|
|
43
|
-
"@kuckit/auth": "^
|
|
44
|
-
"@kuckit/db": "^
|
|
45
|
-
"@kuckit/contracts": "^
|
|
43
|
+
"@kuckit/auth": "^2.0.1",
|
|
44
|
+
"@kuckit/db": "^2.0.1",
|
|
45
|
+
"@kuckit/contracts": "^2.0.1"
|
|
46
46
|
}
|
|
47
47
|
}
|