katanakit-js 6.2.0 → 6.6.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/README.md +11 -3
- package/dist/adapters/better-auth/better-auth.service.d.ts +83 -0
- package/dist/adapters/better-auth/better-auth.service.d.ts.map +1 -0
- package/dist/adapters/better-auth/better-auth.service.js +110 -0
- package/dist/adapters/better-auth/better-auth.service.js.map +1 -0
- package/dist/adapters/better-auth/client.d.ts +51 -0
- package/dist/adapters/better-auth/client.d.ts.map +1 -0
- package/dist/adapters/better-auth/client.js +67 -0
- package/dist/adapters/better-auth/client.js.map +1 -0
- package/dist/adapters/better-auth/index.d.ts +3 -0
- package/dist/adapters/better-auth/index.d.ts.map +1 -0
- package/dist/adapters/better-auth/index.js +3 -0
- package/dist/adapters/better-auth/index.js.map +1 -0
- package/dist/adapters/express/server.d.ts +133 -1
- package/dist/adapters/express/server.d.ts.map +1 -1
- package/dist/adapters/express/server.js +199 -97
- package/dist/adapters/express/server.js.map +1 -1
- package/dist/adapters/index.d.ts +2 -0
- package/dist/adapters/index.d.ts.map +1 -1
- package/dist/adapters/index.js +2 -0
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/insforge/insforge.service.d.ts +139 -4
- package/dist/adapters/insforge/insforge.service.d.ts.map +1 -1
- package/dist/adapters/insforge/insforge.service.js +383 -213
- package/dist/adapters/insforge/insforge.service.js.map +1 -1
- package/dist/adapters/notion/notion.service.d.ts +130 -144
- package/dist/adapters/notion/notion.service.d.ts.map +1 -1
- package/dist/adapters/notion/notion.service.js +330 -341
- package/dist/adapters/notion/notion.service.js.map +1 -1
- package/dist/adapters/photoswipe/index.d.ts +2 -0
- package/dist/adapters/photoswipe/index.d.ts.map +1 -0
- package/dist/adapters/photoswipe/index.js +2 -0
- package/dist/adapters/photoswipe/index.js.map +1 -0
- package/dist/adapters/photoswipe/photoswipe.service.d.ts +99 -0
- package/dist/adapters/photoswipe/photoswipe.service.d.ts.map +1 -0
- package/dist/adapters/photoswipe/photoswipe.service.js +150 -0
- package/dist/adapters/photoswipe/photoswipe.service.js.map +1 -0
- package/dist/adapters/telegram/telegram.service.d.ts +82 -13
- package/dist/adapters/telegram/telegram.service.d.ts.map +1 -1
- package/dist/adapters/telegram/telegram.service.js +133 -55
- package/dist/adapters/telegram/telegram.service.js.map +1 -1
- package/dist/adapters/wordpress/wordpress.service.d.ts +181 -110
- package/dist/adapters/wordpress/wordpress.service.d.ts.map +1 -1
- package/dist/adapters/wordpress/wordpress.service.js +556 -465
- package/dist/adapters/wordpress/wordpress.service.js.map +1 -1
- package/dist/config/seo.service.d.ts +1 -1
- package/dist/config/seo.service.d.ts.map +1 -1
- package/dist/config/seo.service.js +1 -1
- package/dist/config/seo.service.js.map +1 -1
- package/dist/core/services/access.service.d.ts +167 -4
- package/dist/core/services/access.service.d.ts.map +1 -1
- package/dist/core/services/access.service.js +241 -31
- package/dist/core/services/access.service.js.map +1 -1
- package/dist/core/services/agent.service.d.ts +182 -27
- package/dist/core/services/agent.service.d.ts.map +1 -1
- package/dist/core/services/agent.service.js +296 -164
- package/dist/core/services/agent.service.js.map +1 -1
- package/dist/core/services/assistant.service.d.ts +96 -5
- package/dist/core/services/assistant.service.d.ts.map +1 -1
- package/dist/core/services/assistant.service.js +171 -66
- package/dist/core/services/assistant.service.js.map +1 -1
- package/dist/core/services/dates.service.d.ts +183 -11
- package/dist/core/services/dates.service.d.ts.map +1 -1
- package/dist/core/services/dates.service.js +256 -57
- package/dist/core/services/dates.service.js.map +1 -1
- package/dist/core/services/http.service.d.ts +172 -133
- package/dist/core/services/http.service.d.ts.map +1 -1
- package/dist/core/services/http.service.js +367 -310
- package/dist/core/services/http.service.js.map +1 -1
- package/dist/core/services/logger.service.d.ts +96 -34
- package/dist/core/services/logger.service.d.ts.map +1 -1
- package/dist/core/services/logger.service.js +128 -41
- package/dist/core/services/logger.service.js.map +1 -1
- package/dist/core/services/query.service.d.ts +101 -0
- package/dist/core/services/query.service.d.ts.map +1 -1
- package/dist/core/services/query.service.js +131 -14
- package/dist/core/services/query.service.js.map +1 -1
- package/dist/core/services/utils.service.d.ts +286 -131
- package/dist/core/services/utils.service.d.ts.map +1 -1
- package/dist/core/services/utils.service.js +417 -227
- package/dist/core/services/utils.service.js.map +1 -1
- package/dist/core/services/validation.service.d.ts +48 -3
- package/dist/core/services/validation.service.d.ts.map +1 -1
- package/dist/core/services/validation.service.js +75 -23
- package/dist/core/services/validation.service.js.map +1 -1
- package/dist/infrastructure/decorators/cache.decorator.d.ts +53 -0
- package/dist/infrastructure/decorators/cache.decorator.d.ts.map +1 -0
- package/dist/infrastructure/decorators/cache.decorator.js +47 -0
- package/dist/infrastructure/decorators/cache.decorator.js.map +1 -0
- package/dist/infrastructure/decorators/index.d.ts +4 -0
- package/dist/infrastructure/decorators/index.d.ts.map +1 -0
- package/dist/infrastructure/decorators/index.js +4 -0
- package/dist/infrastructure/decorators/index.js.map +1 -0
- package/dist/infrastructure/decorators/logger.decorator.d.ts +38 -0
- package/dist/infrastructure/decorators/logger.decorator.d.ts.map +1 -0
- package/dist/infrastructure/decorators/logger.decorator.js +66 -0
- package/dist/infrastructure/decorators/logger.decorator.js.map +1 -0
- package/dist/infrastructure/decorators/retry.decorator.d.ts +37 -0
- package/dist/infrastructure/decorators/retry.decorator.d.ts.map +1 -0
- package/dist/infrastructure/decorators/retry.decorator.js +54 -0
- package/dist/infrastructure/decorators/retry.decorator.js.map +1 -0
- package/dist/infrastructure/index.d.ts +1 -0
- package/dist/infrastructure/index.d.ts.map +1 -1
- package/dist/infrastructure/index.js +1 -0
- package/dist/infrastructure/index.js.map +1 -1
- package/dist/styles.css +2 -0
- package/package.json +49 -14
- package/scss/_flags.scss +179 -0
- package/scss/_functions.scss +168 -0
- package/scss/_mixins.scss +658 -0
- package/scss/_reset.scss +275 -0
- package/scss/_utilities.scss +449 -0
- package/scss/_variables.scss +539 -0
- package/scss/components/_index.scss +50 -0
- package/scss/demo.scss +12 -0
- package/scss/main.scss +56 -0
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ In the browser, use jsDelivr **`/+esm`** so named exports and dependencies resol
|
|
|
29
29
|
| **esm.sh** | `https://esm.sh/katanakit-js` |
|
|
30
30
|
| **Raw ESM file** | `https://cdn.jsdelivr.net/npm/katanakit-js/dist/index.js` (needs bundler or import map) |
|
|
31
31
|
|
|
32
|
-
Pin a version in production (e.g. `@6.1
|
|
32
|
+
Pin a version in production (e.g. `@6.6.1/+esm`). There is no IIFE/UMD build.
|
|
33
33
|
|
|
34
34
|
## Quick Start
|
|
35
35
|
|
|
@@ -361,11 +361,12 @@ const stop = useKatanaWatch(newProduct, () => checkValidations(), { deep: true }
|
|
|
361
361
|
- **Zod validation everywhere** — `types/` is the single source of truth, inferred from Zod schemas via `z.infer`; `useValidate()` turns any schema into a Safe Result and API adapters validate every response at the boundary
|
|
362
362
|
- **Zero side effects** — importing any module is safe. No `fetch` calls, no `console.log`, no storage writes
|
|
363
363
|
- **Hexagonal architecture** — pure core, infrastructure adapters, framework adapters
|
|
364
|
-
- **
|
|
364
|
+
- **Design patterns** — services are Singleton classes (`getInstance()`) with swappable Strategy implementations (`AccessService`, `AgentService`), a `QueryClientFactory` for per-request SSR clients, and composable Decorators exported from the main barrel: `RetryDecorator`, `CacheDecorator` (TTL memoization) and `LoggerDecorator` (timing traces)
|
|
365
|
+
- **Tree-shakeable** — stable `use*` wrapper functions over the Singleton facades
|
|
365
366
|
- **SSR-safe** — all infrastructure adapters guard or fall back gracefully in server environments
|
|
366
367
|
- **Filesystem (Node/Bun)** — `useReadFile`, `useWriteFile`, `useReadJsonFile`, `useReadModuleJson`, `useHashFile` and friends return Safe Results with native errno codes, loaded lazily through dynamic `import()` and guarded by `useIsNode()`
|
|
367
368
|
- **Fake data (optional)** — `useFakeVehicle`, `useFakeEmail`, `useFakeList`, … via an optional, lazy-loaded `@faker-js/faker` peer
|
|
368
|
-
- **Katana UI** — framework-agnostic component foundations (`useButton`, `useInput`, `useCard`, `useBadge`, `useAlert`) live in the private `@katanakit/ui` workspace, styled with `katanakit-
|
|
369
|
+
- **Katana UI** — framework-agnostic component foundations (`useButton`, `useInput`, `useCard`, `useBadge`, `useAlert`) live in the private `@katanakit/ui` workspace, styled with the SCSS framework vendored in `katanakit-js` (see [UI Kit](https://docs.senseikatana.com/ui-kit/))
|
|
369
370
|
|
|
370
371
|
## Filesystem (Node/Bun)
|
|
371
372
|
|
|
@@ -819,6 +820,13 @@ See [Getting Started](https://docs.senseikatana.com/guides/getting-started) for
|
|
|
819
820
|
| **Telegram** | `katanakit-js/adapters/telegram` | BotFather bot (`defineTelegramConfig`, `useStartTelegramPolling`) |
|
|
820
821
|
| **WhatsApp** | `katanakit-js/adapters/whatsapp` | Meta Cloud API (`defineWhatsAppConfig`, `useStartWhatsApp`) |
|
|
821
822
|
|
|
823
|
+
## UI and Auth Adapters
|
|
824
|
+
|
|
825
|
+
| Adapter | Import | Description |
|
|
826
|
+
| --------------- | ---------------------------------------- | -------------------------------------------------------------- |
|
|
827
|
+
| **PhotoSwipe** | `katanakit-js/adapters/photoswipe` | Lightbox bound by CSS selectors, Safe Result, SSR-safe |
|
|
828
|
+
| **Better Auth** | `katanakit-js/adapters/better-auth` | Auth client (vanilla/react/vue/svelte/solid) + session helpers |
|
|
829
|
+
|
|
822
830
|
## REST API Adapters
|
|
823
831
|
|
|
824
832
|
Typed adapters for popular REST APIs with auth, pagination helpers, and full TypeScript types.
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { Auth, Session, User } from "better-auth";
|
|
2
|
+
import type { AuthResult } from "./client.js";
|
|
3
|
+
/** What `auth.api.getSession()` resolves to when a session exists. */
|
|
4
|
+
export interface AuthSessionData {
|
|
5
|
+
user: User;
|
|
6
|
+
session: Session;
|
|
7
|
+
/** Plugins append their own fields (organization, roles, …). */
|
|
8
|
+
[key: string]: unknown;
|
|
9
|
+
}
|
|
10
|
+
/** The shape `Astro.locals` (or any framework's request context) ends up with. */
|
|
11
|
+
export interface AuthLocals {
|
|
12
|
+
user: User | null;
|
|
13
|
+
session: Session | null;
|
|
14
|
+
}
|
|
15
|
+
/** Anything that carries request headers: a `Request`, `Headers` or `{ headers }`. */
|
|
16
|
+
export type HeadersLike = Headers | Request | {
|
|
17
|
+
headers: Headers;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Reads the current session server-side without throwing.
|
|
21
|
+
*
|
|
22
|
+
* Returns `data: null` with `ok: true` for an anonymous visitor — only a real
|
|
23
|
+
* failure (bad config, network, malformed response) turns into `ok: false`.
|
|
24
|
+
*
|
|
25
|
+
* @param auth - The `betterAuth()` server instance
|
|
26
|
+
* @param request - A `Request`, its `Headers`, or any object exposing `headers`
|
|
27
|
+
* @returns Safe result with the session (or `null`)
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* const session = await useAuthSession(auth, request);
|
|
32
|
+
* if (session.ok && session.data) console.log(session.data.user.email);
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function useAuthSession(auth: Auth, request: HeadersLike): Promise<AuthResult<AuthSessionData | null>>;
|
|
36
|
+
/**
|
|
37
|
+
* Runs Better Auth's request handler (`auth.handler`) for a catch-all route.
|
|
38
|
+
*
|
|
39
|
+
* @param auth - The `betterAuth()` server instance
|
|
40
|
+
* @param request - The incoming `Request`
|
|
41
|
+
* @returns Safe result with the handler's `Response`
|
|
42
|
+
*
|
|
43
|
+
* @example Astro — `src/pages/api/auth/[...all].ts`
|
|
44
|
+
* ```ts
|
|
45
|
+
* import type { APIRoute } from "astro";
|
|
46
|
+
* import { auth } from "~/auth";
|
|
47
|
+
* import { useAuthHandler } from "katanakit-js/adapters/better-auth";
|
|
48
|
+
*
|
|
49
|
+
* export const ALL: APIRoute = async ({ request }) => {
|
|
50
|
+
* const result = await useAuthHandler(auth, request);
|
|
51
|
+
* return result.ok ? result.data : new Response("Auth unavailable", { status: 500 });
|
|
52
|
+
* };
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare function useAuthHandler(auth: Auth, request: Request): Promise<AuthResult<Response>>;
|
|
56
|
+
/**
|
|
57
|
+
* Builds the `user` / `session` pair middleware puts into the request context.
|
|
58
|
+
*
|
|
59
|
+
* Mirrors Better Auth's Astro middleware: anonymous visitors get `null` for
|
|
60
|
+
* both fields instead of an error, so a page can branch on `locals.user`.
|
|
61
|
+
*
|
|
62
|
+
* @param auth - The `betterAuth()` server instance
|
|
63
|
+
* @param request - The incoming `Request` (or anything carrying its headers)
|
|
64
|
+
* @returns Safe result with `{ user, session }`
|
|
65
|
+
*
|
|
66
|
+
* @example Astro — `src/middleware.ts`
|
|
67
|
+
* ```ts
|
|
68
|
+
* import { defineMiddleware } from "astro:middleware";
|
|
69
|
+
* import { auth } from "~/auth";
|
|
70
|
+
* import { useAstroAuthLocals } from "katanakit-js/adapters/better-auth";
|
|
71
|
+
*
|
|
72
|
+
* export const onRequest = defineMiddleware(async (context, next) => {
|
|
73
|
+
* const locals = await useAstroAuthLocals(auth, context.request);
|
|
74
|
+
* if (locals.ok) {
|
|
75
|
+
* context.locals.user = locals.data.user;
|
|
76
|
+
* context.locals.session = locals.data.session;
|
|
77
|
+
* }
|
|
78
|
+
* return next();
|
|
79
|
+
* });
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
export declare function useAstroAuthLocals(auth: Auth, request: HeadersLike): Promise<AuthResult<AuthLocals>>;
|
|
83
|
+
//# sourceMappingURL=better-auth.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"better-auth.service.d.ts","sourceRoot":"","sources":["../../../src/adapters/better-auth/better-auth.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,sEAAsE;AACtE,MAAM,WAAW,eAAe;IAC/B,IAAI,EAAE,IAAI,CAAC;IACX,OAAO,EAAE,OAAO,CAAC;IACjB,gEAAgE;IAChE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACvB;AAED,kFAAkF;AAClF,MAAM,WAAW,UAAU;IAC1B,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;CACxB;AAED,sFAAsF;AACtF,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,OAAO,GAAG;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC;AAQnE;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,cAAc,CACnC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,WAAW,GAClB,OAAO,CAAC,UAAU,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC,CAa7C;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAWhG;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,kBAAkB,CACvC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,WAAW,GAClB,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CASjC"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
function toHeaders(input) {
|
|
2
|
+
if (input instanceof Headers)
|
|
3
|
+
return input;
|
|
4
|
+
if (input && typeof input === "object" && "headers" in input)
|
|
5
|
+
return input.headers;
|
|
6
|
+
return new Headers();
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Reads the current session server-side without throwing.
|
|
10
|
+
*
|
|
11
|
+
* Returns `data: null` with `ok: true` for an anonymous visitor — only a real
|
|
12
|
+
* failure (bad config, network, malformed response) turns into `ok: false`.
|
|
13
|
+
*
|
|
14
|
+
* @param auth - The `betterAuth()` server instance
|
|
15
|
+
* @param request - A `Request`, its `Headers`, or any object exposing `headers`
|
|
16
|
+
* @returns Safe result with the session (or `null`)
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* const session = await useAuthSession(auth, request);
|
|
21
|
+
* if (session.ok && session.data) console.log(session.data.user.email);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export async function useAuthSession(auth, request) {
|
|
25
|
+
try {
|
|
26
|
+
const data = (await auth.api.getSession({
|
|
27
|
+
headers: toHeaders(request),
|
|
28
|
+
}));
|
|
29
|
+
return { data, error: null, ok: true };
|
|
30
|
+
}
|
|
31
|
+
catch (cause) {
|
|
32
|
+
return {
|
|
33
|
+
data: null,
|
|
34
|
+
error: { message: `[BetterAuth] getSession failed: ${toMessage(cause)}`, details: cause },
|
|
35
|
+
ok: false,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Runs Better Auth's request handler (`auth.handler`) for a catch-all route.
|
|
41
|
+
*
|
|
42
|
+
* @param auth - The `betterAuth()` server instance
|
|
43
|
+
* @param request - The incoming `Request`
|
|
44
|
+
* @returns Safe result with the handler's `Response`
|
|
45
|
+
*
|
|
46
|
+
* @example Astro — `src/pages/api/auth/[...all].ts`
|
|
47
|
+
* ```ts
|
|
48
|
+
* import type { APIRoute } from "astro";
|
|
49
|
+
* import { auth } from "~/auth";
|
|
50
|
+
* import { useAuthHandler } from "katanakit-js/adapters/better-auth";
|
|
51
|
+
*
|
|
52
|
+
* export const ALL: APIRoute = async ({ request }) => {
|
|
53
|
+
* const result = await useAuthHandler(auth, request);
|
|
54
|
+
* return result.ok ? result.data : new Response("Auth unavailable", { status: 500 });
|
|
55
|
+
* };
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export async function useAuthHandler(auth, request) {
|
|
59
|
+
try {
|
|
60
|
+
const response = await auth.handler(request);
|
|
61
|
+
return { data: response, error: null, ok: true };
|
|
62
|
+
}
|
|
63
|
+
catch (cause) {
|
|
64
|
+
return {
|
|
65
|
+
data: null,
|
|
66
|
+
error: { message: `[BetterAuth] handler failed: ${toMessage(cause)}`, details: cause },
|
|
67
|
+
ok: false,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Builds the `user` / `session` pair middleware puts into the request context.
|
|
73
|
+
*
|
|
74
|
+
* Mirrors Better Auth's Astro middleware: anonymous visitors get `null` for
|
|
75
|
+
* both fields instead of an error, so a page can branch on `locals.user`.
|
|
76
|
+
*
|
|
77
|
+
* @param auth - The `betterAuth()` server instance
|
|
78
|
+
* @param request - The incoming `Request` (or anything carrying its headers)
|
|
79
|
+
* @returns Safe result with `{ user, session }`
|
|
80
|
+
*
|
|
81
|
+
* @example Astro — `src/middleware.ts`
|
|
82
|
+
* ```ts
|
|
83
|
+
* import { defineMiddleware } from "astro:middleware";
|
|
84
|
+
* import { auth } from "~/auth";
|
|
85
|
+
* import { useAstroAuthLocals } from "katanakit-js/adapters/better-auth";
|
|
86
|
+
*
|
|
87
|
+
* export const onRequest = defineMiddleware(async (context, next) => {
|
|
88
|
+
* const locals = await useAstroAuthLocals(auth, context.request);
|
|
89
|
+
* if (locals.ok) {
|
|
90
|
+
* context.locals.user = locals.data.user;
|
|
91
|
+
* context.locals.session = locals.data.session;
|
|
92
|
+
* }
|
|
93
|
+
* return next();
|
|
94
|
+
* });
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
export async function useAstroAuthLocals(auth, request) {
|
|
98
|
+
const session = await useAuthSession(auth, request);
|
|
99
|
+
if (!session.ok)
|
|
100
|
+
return session;
|
|
101
|
+
return {
|
|
102
|
+
data: { user: session.data?.user ?? null, session: session.data?.session ?? null },
|
|
103
|
+
error: null,
|
|
104
|
+
ok: true,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function toMessage(error) {
|
|
108
|
+
return error instanceof Error ? error.message : String(error);
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=better-auth.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"better-auth.service.js","sourceRoot":"","sources":["../../../src/adapters/better-auth/better-auth.service.ts"],"names":[],"mappings":"AAqBA,SAAS,SAAS,CAAC,KAAkB;IACpC,IAAI,KAAK,YAAY,OAAO;QAAE,OAAO,KAAK,CAAC;IAC3C,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,SAAS,IAAI,KAAK;QAAE,OAAO,KAAK,CAAC,OAAO,CAAC;IACnF,OAAO,IAAI,OAAO,EAAE,CAAC;AACtB,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CACnC,IAAU,EACV,OAAoB;IAEpB,IAAI,CAAC;QACJ,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC;YACvC,OAAO,EAAE,SAAS,CAAC,OAAO,CAAC;SAC3B,CAAC,CAA2B,CAAC;QAC9B,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;IACxC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,OAAO;YACN,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,EAAE,OAAO,EAAE,mCAAmC,SAAS,CAAC,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE;YACzF,EAAE,EAAE,KAAK;SACT,CAAC;IACH,CAAC;AACF,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,IAAU,EAAE,OAAgB;IAChE,IAAI,CAAC;QACJ,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC7C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;IAClD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,OAAO;YACN,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,EAAE,OAAO,EAAE,gCAAgC,SAAS,CAAC,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE;YACtF,EAAE,EAAE,KAAK;SACT,CAAC;IACH,CAAC;AACF,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACvC,IAAU,EACV,OAAoB;IAEpB,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACpD,IAAI,CAAC,OAAO,CAAC,EAAE;QAAE,OAAO,OAAO,CAAC;IAEhC,OAAO;QACN,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,IAAI,IAAI,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,IAAI,IAAI,EAAE;QAClF,KAAK,EAAE,IAAI;QACX,EAAE,EAAE,IAAI;KACR,CAAC;AACH,CAAC;AAED,SAAS,SAAS,CAAC,KAAc;IAChC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { AuthClient, BetterAuthClientOptions } from "better-auth/client";
|
|
2
|
+
import type { ReactAuthClient } from "better-auth/react";
|
|
3
|
+
import type { SolidAuthClient } from "better-auth/solid";
|
|
4
|
+
import type { SvelteAuthClient } from "better-auth/svelte";
|
|
5
|
+
import type { VueAuthClient } from "better-auth/vue";
|
|
6
|
+
import type { SafeResult } from "../../types/index.js";
|
|
7
|
+
/** Framework clients shipped by Better Auth — one `createAuthClient` per entry. */
|
|
8
|
+
export type AuthFramework = "vanilla" | "react" | "vue" | "svelte" | "solid";
|
|
9
|
+
export type { AuthClient, BetterAuthClientOptions };
|
|
10
|
+
/** Client type the requested framework's `createAuthClient` returns. */
|
|
11
|
+
export type AuthClientFor<F extends AuthFramework, O extends BetterAuthClientOptions = BetterAuthClientOptions> = F extends "vue" ? VueAuthClient<O> : F extends "react" ? ReactAuthClient<O> : F extends "svelte" ? SvelteAuthClient<O> : F extends "solid" ? SolidAuthClient<O> : AuthClient<O>;
|
|
12
|
+
export interface AuthClientOptions<F extends AuthFramework = "vanilla"> extends BetterAuthClientOptions {
|
|
13
|
+
/**
|
|
14
|
+
* Which Better Auth client entry to load.
|
|
15
|
+
*
|
|
16
|
+
* @defaultValue `"vanilla"`
|
|
17
|
+
*/
|
|
18
|
+
framework?: F;
|
|
19
|
+
}
|
|
20
|
+
export type AuthError = {
|
|
21
|
+
message: string;
|
|
22
|
+
details?: unknown;
|
|
23
|
+
};
|
|
24
|
+
export type AuthResult<T> = SafeResult<T, AuthError>;
|
|
25
|
+
/**
|
|
26
|
+
* Creates the Better Auth client for the requested framework, importing only
|
|
27
|
+
* that entry — the other four never reach the bundle.
|
|
28
|
+
*
|
|
29
|
+
* @param options - `BetterAuthClientOptions` (`baseURL`, `plugins`, …) plus `framework`
|
|
30
|
+
* @returns Safe result with the framework's typed client; never throws
|
|
31
|
+
*
|
|
32
|
+
* @example Vue / Nuxt — `lib/auth-client.ts`
|
|
33
|
+
* ```ts
|
|
34
|
+
* import { useAuthClient } from "katanakit-js/adapters/better-auth";
|
|
35
|
+
*
|
|
36
|
+
* export const authClient = await useAuthClient({ framework: "vue" });
|
|
37
|
+
* export const { signIn, signUp, signOut, useSession } = authClient;
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @example React
|
|
41
|
+
* ```ts
|
|
42
|
+
* const authClient = await useAuthClient({ framework: "react", baseURL: "https://auth.example.com" });
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @example Vanilla (Astro island-free pages, plain `<script>`)
|
|
46
|
+
* ```ts
|
|
47
|
+
* const authClient = await useAuthClient();
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare function useAuthClient<F extends AuthFramework = "vanilla">(options?: AuthClientOptions<F>): Promise<AuthResult<AuthClientFor<F>>>;
|
|
51
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/adapters/better-auth/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,mFAAmF;AACnF,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC;AAE7E,YAAY,EAAE,UAAU,EAAE,uBAAuB,EAAE,CAAC;AAEpD,wEAAwE;AACxE,MAAM,MAAM,aAAa,CACxB,CAAC,SAAS,aAAa,EACvB,CAAC,SAAS,uBAAuB,GAAG,uBAAuB,IACxD,CAAC,SAAS,KAAK,GAChB,aAAa,CAAC,CAAC,CAAC,GAChB,CAAC,SAAS,OAAO,GAChB,eAAe,CAAC,CAAC,CAAC,GAClB,CAAC,SAAS,QAAQ,GACjB,gBAAgB,CAAC,CAAC,CAAC,GACnB,CAAC,SAAS,OAAO,GAChB,eAAe,CAAC,CAAC,CAAC,GAClB,UAAU,CAAC,CAAC,CAAC,CAAC;AAEpB,MAAM,WAAW,iBAAiB,CACjC,CAAC,SAAS,aAAa,GAAG,SAAS,CAClC,SAAQ,uBAAuB;IAChC;;;;OAIG;IACH,SAAS,CAAC,EAAE,CAAC,CAAC;CACd;AAED,MAAM,MAAM,SAAS,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAC/D,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,aAAa,CAAC,CAAC,SAAS,aAAa,GAAG,SAAS,EACtE,OAAO,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAC5B,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAwCvC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates the Better Auth client for the requested framework, importing only
|
|
3
|
+
* that entry — the other four never reach the bundle.
|
|
4
|
+
*
|
|
5
|
+
* @param options - `BetterAuthClientOptions` (`baseURL`, `plugins`, …) plus `framework`
|
|
6
|
+
* @returns Safe result with the framework's typed client; never throws
|
|
7
|
+
*
|
|
8
|
+
* @example Vue / Nuxt — `lib/auth-client.ts`
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { useAuthClient } from "katanakit-js/adapters/better-auth";
|
|
11
|
+
*
|
|
12
|
+
* export const authClient = await useAuthClient({ framework: "vue" });
|
|
13
|
+
* export const { signIn, signUp, signOut, useSession } = authClient;
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @example React
|
|
17
|
+
* ```ts
|
|
18
|
+
* const authClient = await useAuthClient({ framework: "react", baseURL: "https://auth.example.com" });
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @example Vanilla (Astro island-free pages, plain `<script>`)
|
|
22
|
+
* ```ts
|
|
23
|
+
* const authClient = await useAuthClient();
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export async function useAuthClient(options) {
|
|
27
|
+
const { framework, ...clientOptions } = (options ?? {});
|
|
28
|
+
try {
|
|
29
|
+
switch (framework) {
|
|
30
|
+
case "vue": {
|
|
31
|
+
const { createAuthClient } = await import("better-auth/vue");
|
|
32
|
+
return ok(createAuthClient(clientOptions));
|
|
33
|
+
}
|
|
34
|
+
case "react": {
|
|
35
|
+
const { createAuthClient } = await import("better-auth/react");
|
|
36
|
+
return ok(createAuthClient(clientOptions));
|
|
37
|
+
}
|
|
38
|
+
case "svelte": {
|
|
39
|
+
const { createAuthClient } = await import("better-auth/svelte");
|
|
40
|
+
return ok(createAuthClient(clientOptions));
|
|
41
|
+
}
|
|
42
|
+
case "solid": {
|
|
43
|
+
const { createAuthClient } = await import("better-auth/solid");
|
|
44
|
+
return ok(createAuthClient(clientOptions));
|
|
45
|
+
}
|
|
46
|
+
default: {
|
|
47
|
+
const { createAuthClient } = await import("better-auth/client");
|
|
48
|
+
return ok(createAuthClient(clientOptions));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch (cause) {
|
|
53
|
+
return {
|
|
54
|
+
data: null,
|
|
55
|
+
error: {
|
|
56
|
+
message: `[BetterAuth] cannot load the "${framework ?? "vanilla"}" client — ` +
|
|
57
|
+
"install it with `bun add better-auth`.",
|
|
58
|
+
details: cause,
|
|
59
|
+
},
|
|
60
|
+
ok: false,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function ok(data) {
|
|
65
|
+
return { data, error: null, ok: true };
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/adapters/better-auth/client.ts"],"names":[],"mappings":"AAyCA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAClC,OAA8B;IAE9B,MAAM,EAAE,SAAS,EAAE,GAAG,aAAa,EAAE,GAAG,CAAC,OAAO,IAAI,EAAE,CAErD,CAAC;IAEF,IAAI,CAAC;QACJ,QAAQ,SAAS,EAAE,CAAC;YACnB,KAAK,KAAK,CAAC,CAAC,CAAC;gBACZ,MAAM,EAAE,gBAAgB,EAAE,GAAG,MAAM,MAAM,CAAC,iBAAiB,CAAC,CAAC;gBAC7D,OAAO,EAAE,CAAC,gBAAgB,CAAC,aAAa,CAAqB,CAAC,CAAC;YAChE,CAAC;YACD,KAAK,OAAO,CAAC,CAAC,CAAC;gBACd,MAAM,EAAE,gBAAgB,EAAE,GAAG,MAAM,MAAM,CAAC,mBAAmB,CAAC,CAAC;gBAC/D,OAAO,EAAE,CAAC,gBAAgB,CAAC,aAAa,CAAqB,CAAC,CAAC;YAChE,CAAC;YACD,KAAK,QAAQ,CAAC,CAAC,CAAC;gBACf,MAAM,EAAE,gBAAgB,EAAE,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,CAAC;gBAChE,OAAO,EAAE,CAAC,gBAAgB,CAAC,aAAa,CAAqB,CAAC,CAAC;YAChE,CAAC;YACD,KAAK,OAAO,CAAC,CAAC,CAAC;gBACd,MAAM,EAAE,gBAAgB,EAAE,GAAG,MAAM,MAAM,CAAC,mBAAmB,CAAC,CAAC;gBAC/D,OAAO,EAAE,CAAC,gBAAgB,CAAC,aAAa,CAAqB,CAAC,CAAC;YAChE,CAAC;YACD,OAAO,CAAC,CAAC,CAAC;gBACT,MAAM,EAAE,gBAAgB,EAAE,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,CAAC;gBAChE,OAAO,EAAE,CAAC,gBAAgB,CAAC,aAAa,CAAqB,CAAC,CAAC;YAChE,CAAC;QACF,CAAC;IACF,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,OAAO;YACN,IAAI,EAAE,IAAI;YACV,KAAK,EAAE;gBACN,OAAO,EACN,iCAAiC,SAAS,IAAI,SAAS,aAAa;oBACpE,wCAAwC;gBACzC,OAAO,EAAE,KAAK;aACd;YACD,EAAE,EAAE,KAAK;SACT,CAAC;IACH,CAAC;AACF,CAAC;AAED,SAAS,EAAE,CAAI,IAAO;IACrB,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/better-auth/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/adapters/better-auth/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC"}
|
|
@@ -1,4 +1,136 @@
|
|
|
1
1
|
import { type Application, type Request } from "express";
|
|
2
|
+
/**
|
|
3
|
+
* ExpressService - Singleton para el servidor Express.
|
|
4
|
+
*
|
|
5
|
+
* Aplica el patrón Singleton: una única instancia centraliza la creación,
|
|
6
|
+
* configuración de middlewares, rutas, manejo de errores y ciclo de vida del
|
|
7
|
+
* servidor HTTP (start/stop). Idempotente: crear, finalizar y arrancar son
|
|
8
|
+
* operaciones seguras de repetir.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const app = ExpressService.getInstance().useCreate();
|
|
13
|
+
* app.use("/assistant", useCreateAssistantRouter());
|
|
14
|
+
* ExpressService.getInstance().useStart(3000, "localhost");
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare class ExpressService {
|
|
18
|
+
private static instance;
|
|
19
|
+
/** Express application instance. */
|
|
20
|
+
private app;
|
|
21
|
+
/** Whether the HTTP server has been started. */
|
|
22
|
+
private started;
|
|
23
|
+
/** Whether the error handler / 404 catch-all has been registered. */
|
|
24
|
+
private finalized;
|
|
25
|
+
/**
|
|
26
|
+
* Constructor privado - enforce singleton.
|
|
27
|
+
*/
|
|
28
|
+
private constructor();
|
|
29
|
+
/**
|
|
30
|
+
* Obtiene la instancia única del ExpressService (Singleton).
|
|
31
|
+
*
|
|
32
|
+
* @returns La instancia única de {@link ExpressService}.
|
|
33
|
+
*/
|
|
34
|
+
static getInstance(): ExpressService;
|
|
35
|
+
/**
|
|
36
|
+
* Returns the raw request body buffer captured by the JSON parser, if any.
|
|
37
|
+
* Needed to verify webhook signatures (e.g. `X-Hub-Signature-256`).
|
|
38
|
+
*
|
|
39
|
+
* @param request - The Express request.
|
|
40
|
+
* @returns The raw body buffer, or `undefined` when not available.
|
|
41
|
+
*/
|
|
42
|
+
useGetRawBody(request: Request): Buffer | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Set up CORS, JSON body parser and URL-encoded middleware.
|
|
45
|
+
* The JSON parser also captures the raw body for signature verification.
|
|
46
|
+
*
|
|
47
|
+
* @param expressApp - Express application instance
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* const expressApp = express();
|
|
52
|
+
* useExpressSetupMiddlewares(expressApp);
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
private useSetupMiddlewares;
|
|
56
|
+
/**
|
|
57
|
+
* Set up health check and application routes.
|
|
58
|
+
*
|
|
59
|
+
* @param expressApp - Express application instance
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* useExpressSetupRoutes(expressApp);
|
|
64
|
+
* // GET /health returns { status: "ok", timestamp: "..." }
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
private useSetupRoutes;
|
|
68
|
+
/**
|
|
69
|
+
* Set up global error handling and 404 fallback. Register this AFTER all
|
|
70
|
+
* channel routers are mounted so it does not shadow them.
|
|
71
|
+
*
|
|
72
|
+
* @param expressApp - Express application instance
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* useExpressSetupErrorHandling(expressApp);
|
|
77
|
+
* // Unhandled errors return 500, unknown routes return 404
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
private useSetupErrorHandling;
|
|
81
|
+
/**
|
|
82
|
+
* Create and configure the Express application. Mount channel routers on the
|
|
83
|
+
* returned app BEFORE calling {@link useFinalize} / {@link useStart},
|
|
84
|
+
* otherwise the 404 catch-all will shadow them.
|
|
85
|
+
*
|
|
86
|
+
* @returns Configured Express Application instance
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```ts
|
|
90
|
+
* const expressApp = ExpressService.getInstance().useCreate();
|
|
91
|
+
* expressApp.use("/assistant", useCreateAssistantRouter());
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
useCreate(): Application;
|
|
95
|
+
/**
|
|
96
|
+
* Registers the error handler and 404 catch-all. Idempotent. Call this after
|
|
97
|
+
* mounting every channel router so it runs last. {@link useStart}
|
|
98
|
+
* invokes it automatically.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```ts
|
|
102
|
+
* ExpressService.getInstance().useGetApp().use("/assistant", useCreateAssistantRouter());
|
|
103
|
+
* ExpressService.getInstance().useFinalize();
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
useFinalize(): void;
|
|
107
|
+
/**
|
|
108
|
+
* Start the Express HTTP server. Idempotent - subsequent calls are no-ops.
|
|
109
|
+
* Finalizes error handling before listening.
|
|
110
|
+
*
|
|
111
|
+
* @param port - Port to listen on (default: 3000)
|
|
112
|
+
* @param host - Host to bind to (default: "localhost")
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```ts
|
|
116
|
+
* ExpressService.getInstance().useStart(3000, "localhost");
|
|
117
|
+
* // Server running on http://localhost:3000
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
useStart(port?: number, host?: string): void;
|
|
121
|
+
/**
|
|
122
|
+
* Get the Express application instance. Creates it if it doesn't exist.
|
|
123
|
+
*
|
|
124
|
+
* @returns Express Application instance
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```ts
|
|
128
|
+
* const expressApp = ExpressService.getInstance().useGetApp();
|
|
129
|
+
* expressApp.get("/custom", (req, res) => res.json({ ok: true }));
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
useGetApp(): Application;
|
|
133
|
+
}
|
|
2
134
|
/**
|
|
3
135
|
* Returns the raw request body buffer captured by the JSON parser, if any.
|
|
4
136
|
* Needed to verify webhook signatures (e.g. `X-Hub-Signature-256`).
|
|
@@ -35,7 +167,7 @@ export declare const useExpressCreate: () => Application;
|
|
|
35
167
|
*/
|
|
36
168
|
export declare const useExpressFinalize: () => void;
|
|
37
169
|
/**
|
|
38
|
-
* Start the Express HTTP server. Idempotent
|
|
170
|
+
* Start the Express HTTP server. Idempotent - subsequent calls are no-ops.
|
|
39
171
|
* Finalizes error handling before listening.
|
|
40
172
|
*
|
|
41
173
|
* @param port - Port to listen on (default: 3000)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/adapters/express/server.ts"],"names":[],"mappings":"AAGA,OAAgB,EAAE,KAAK,WAAW,EAAqB,KAAK,OAAO,EAAiB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/adapters/express/server.ts"],"names":[],"mappings":"AAGA,OAAgB,EAAE,KAAK,WAAW,EAAqB,KAAK,OAAO,EAAiB,MAAM,SAAS,CAAC;AAQpG;;;;;;;;;;;;;;GAcG;AACH,qBAAa,cAAc;IAC1B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAiB;IAExC,oCAAoC;IACpC,OAAO,CAAC,GAAG,CAA4B;IACvC,gDAAgD;IAChD,OAAO,CAAC,OAAO,CAAS;IACxB,qEAAqE;IACrE,OAAO,CAAC,SAAS,CAAS;IAE1B;;OAEG;IACH,OAAO;IAEP;;;;OAIG;IACH,MAAM,CAAC,WAAW,IAAI,cAAc;IAOpC;;;;;;OAMG;IACH,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS;IAInD;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,mBAAmB;IAuB3B;;;;;;;;;;OAUG;IACH,OAAO,CAAC,cAAc;IAWtB;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,qBAAqB;IAW7B;;;;;;;;;;;;OAYG;IACH,SAAS,IAAI,WAAW;IAUxB;;;;;;;;;;OAUG;IACH,WAAW,IAAI,IAAI;IAMnB;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,IAAI,SAAO,EAAE,IAAI,SAAc,GAAG,IAAI;IAY/C;;;;;;;;;;OAUG;IACH,SAAS,IAAI,WAAW;CAGxB;AAMD;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAElE;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,gBAAgB,QAAO,WAAuD,CAAC;AAE5F;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kBAAkB,QAAO,IAAkD,CAAC;AAEzF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,GAAI,aAAW,EAAE,aAAkB,KAAG,IAChB,CAAC;AAEnD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,QAAO,WAAuD,CAAC"}
|