@arkstack/driver-h3 0.12.37 → 0.13.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/{index-E-098om7.d.ts → index-CrRoMPZ1.d.ts} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -1223
- package/dist/middlewares/index.d.ts +14 -2
- package/dist/middlewares/index.js +2 -2
- package/dist/{middlewares-CGBJHsH7.js → middlewares-DWDWNHGY.js} +31 -3
- package/dist/types.d.ts +1 -1
- package/package.json +7 -7
- package/dist/index--GiaEPJz.d.ts +0 -91
- package/dist/types-DPGHB4nY.d.ts +0 -18
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as H3Middleware } from "../index
|
|
1
|
+
import { i as H3Middleware } from "../index-CrRoMPZ1.js";
|
|
2
2
|
import * as _$h3 from "h3";
|
|
3
3
|
import { EventHandlerRequest, H3Event } from "h3";
|
|
4
4
|
import { NextFunction } from "clear-router/types/h3";
|
|
@@ -56,7 +56,19 @@ declare class RequestLoggerMiddleware {
|
|
|
56
56
|
handler(): H3Middleware;
|
|
57
57
|
}
|
|
58
58
|
//#endregion
|
|
59
|
+
//#region src/middlewares/resora.d.ts
|
|
60
|
+
/**
|
|
61
|
+
* Apply the application's resora configuration (`src/config/resources.ts`) and
|
|
62
|
+
* bind the per-request `{ req, res }` context so Resources can build URLs and
|
|
63
|
+
* pagination links.
|
|
64
|
+
*
|
|
65
|
+
* Replaces the manual `Resource.setCtx(...)` wiring: resora's runtime config is
|
|
66
|
+
* applied from `config('resources')`, and the request is run within resora's
|
|
67
|
+
* async context so downstream handlers resolve the correct context.
|
|
68
|
+
*/
|
|
69
|
+
declare const resora: () => (event: H3Event, next: NextFunction) => Promise<unknown>;
|
|
70
|
+
//#endregion
|
|
59
71
|
//#region src/middlewares/static-asset-handler.d.ts
|
|
60
72
|
declare const staticAssetHandler: (publicPath?: string) => (event: H3Event) => Promise<_$h3.HTTPResponse | undefined> | undefined;
|
|
61
73
|
//#endregion
|
|
62
|
-
export { AuthMiddleware, CorsMiddleware, RequestLoggerMiddleware, auth, cors, requestLogger, staticAssetHandler };
|
|
74
|
+
export { AuthMiddleware, CorsMiddleware, RequestLoggerMiddleware, auth, cors, requestLogger, resora, staticAssetHandler };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { AuthMiddleware, CorsMiddleware, RequestLoggerMiddleware, auth, cors, requestLogger, staticAssetHandler };
|
|
1
|
+
import { a as CorsMiddleware, c as auth, i as requestLogger, n as resora, o as cors, r as RequestLoggerMiddleware, s as AuthMiddleware, t as staticAssetHandler } from "../middlewares-DWDWNHGY.js";
|
|
2
|
+
export { AuthMiddleware, CorsMiddleware, RequestLoggerMiddleware, auth, cors, requestLogger, resora, staticAssetHandler };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Arkstack } from "@arkstack/contract";
|
|
2
2
|
import { serveStatic } from "h3";
|
|
3
|
-
import { Logger, nodeEnv } from "@arkstack/common";
|
|
3
|
+
import { Logger, config, nodeEnv } from "@arkstack/common";
|
|
4
|
+
import { Hook } from "@arkstack/foundry";
|
|
5
|
+
import { applyRuntimeConfig, getDefaultConfig, runWithCtx, setCtx } from "resora";
|
|
4
6
|
import { join, resolve } from "node:path";
|
|
5
7
|
import { readFile, stat } from "node:fs/promises";
|
|
6
|
-
import { Hook } from "@arkstack/foundry";
|
|
7
8
|
//#region src/middlewares/auth.ts
|
|
8
9
|
const auth = async (event, next) => {
|
|
9
10
|
const { Auth, AuthenticationException } = await import("@arkstack/auth");
|
|
@@ -312,6 +313,33 @@ var RequestLoggerMiddleware = class {
|
|
|
312
313
|
}
|
|
313
314
|
};
|
|
314
315
|
//#endregion
|
|
316
|
+
//#region src/middlewares/resora.ts
|
|
317
|
+
/**
|
|
318
|
+
* Apply the application's resora configuration (`src/config/resources.ts`) and
|
|
319
|
+
* bind the per-request `{ req, res }` context so Resources can build URLs and
|
|
320
|
+
* pagination links.
|
|
321
|
+
*
|
|
322
|
+
* Replaces the manual `Resource.setCtx(...)` wiring: resora's runtime config is
|
|
323
|
+
* applied from `config('resources')`, and the request is run within resora's
|
|
324
|
+
* async context so downstream handlers resolve the correct context.
|
|
325
|
+
*/
|
|
326
|
+
const resora = () => {
|
|
327
|
+
return async (event, next) => {
|
|
328
|
+
try {
|
|
329
|
+
applyRuntimeConfig({
|
|
330
|
+
...getDefaultConfig(),
|
|
331
|
+
...config("resources", {})
|
|
332
|
+
});
|
|
333
|
+
} catch {}
|
|
334
|
+
const ctx = {
|
|
335
|
+
req: event.req,
|
|
336
|
+
res: event.res
|
|
337
|
+
};
|
|
338
|
+
setCtx(ctx);
|
|
339
|
+
return runWithCtx(ctx, () => next());
|
|
340
|
+
};
|
|
341
|
+
};
|
|
342
|
+
//#endregion
|
|
315
343
|
//#region src/middlewares/static-asset-handler.ts
|
|
316
344
|
const staticAssetHandler = (publicPath = "public") => {
|
|
317
345
|
const rootPath = resolve(Arkstack.rootDir(), publicPath);
|
|
@@ -339,4 +367,4 @@ const staticAssetHandler = (publicPath = "public") => {
|
|
|
339
367
|
};
|
|
340
368
|
};
|
|
341
369
|
//#endregion
|
|
342
|
-
export {
|
|
370
|
+
export { CorsMiddleware as a, auth as c, requestLogger as i, resora as n, cors as o, RequestLoggerMiddleware as r, AuthMiddleware as s, staticAssetHandler as t };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as MiddlewareConfig, t as Middleware } from "./types-
|
|
1
|
+
import { n as MiddlewareConfig, t as Middleware } from "./types-DWUchLdg.js";
|
|
2
2
|
export { Middleware, MiddlewareConfig };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkstack/driver-h3",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "H3 driver for Arkstack, providing H3-based runtime integration for the framework.",
|
|
6
6
|
"homepage": "https://arkstack.toneflix.net",
|
|
@@ -38,15 +38,15 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"clear-router": "^2.8.8",
|
|
41
|
-
"@resora/plugin-clear-router": "^1.0.
|
|
42
|
-
"resora": "^1.3.
|
|
43
|
-
"@arkstack/contract": "^0.
|
|
41
|
+
"@resora/plugin-clear-router": "^1.0.63",
|
|
42
|
+
"resora": "^1.3.26",
|
|
43
|
+
"@arkstack/contract": "^0.13.1"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"h3": "2.0.1-rc.22",
|
|
47
|
-
"@arkstack/foundry": "^0.
|
|
48
|
-
"@arkstack/auth": "^0.
|
|
49
|
-
"@arkstack/common": "^0.
|
|
47
|
+
"@arkstack/foundry": "^0.13.1",
|
|
48
|
+
"@arkstack/auth": "^0.13.1",
|
|
49
|
+
"@arkstack/common": "^0.13.1"
|
|
50
50
|
},
|
|
51
51
|
"peerDependenciesMeta": {
|
|
52
52
|
"@arkstack/auth": {
|
package/dist/index--GiaEPJz.d.ts
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { n as MiddlewareConfig, t as Middleware$2 } from "./types-DPGHB4nY.js";
|
|
2
|
-
import { ArkstackKitDriver, ArkstackRouteListOptions, PromiseOrValue } from "@arkstack/contract";
|
|
3
|
-
import { H3, H3Event, HTTPError, HTTPResponse } from "h3";
|
|
4
|
-
import { Route } from "clear-router";
|
|
5
|
-
import { Router } from "clear-router/h3";
|
|
6
|
-
import { H3App, Handler, HttpContext, Middleware as Middleware$1 } from "clear-router/types/h3";
|
|
7
|
-
|
|
8
|
-
//#region src/error-handler.d.ts
|
|
9
|
-
declare const defaultErrorHandler: (err: HTTPError | Error | string, event: H3Event) => Promise<HTTPResponse | {
|
|
10
|
-
error: boolean;
|
|
11
|
-
message: string;
|
|
12
|
-
status: "error";
|
|
13
|
-
code: number;
|
|
14
|
-
errors?: unknown;
|
|
15
|
-
stack?: string;
|
|
16
|
-
}>;
|
|
17
|
-
//#endregion
|
|
18
|
-
//#region src/Router.d.ts
|
|
19
|
-
declare class Router$1 extends Router {
|
|
20
|
-
static bind(app: H3): Promise<H3App>;
|
|
21
|
-
static list(_options: ArkstackRouteListOptions | undefined, app: H3): Promise<Route<HttpContext, Middleware$1, Handler>[]>;
|
|
22
|
-
}
|
|
23
|
-
//#endregion
|
|
24
|
-
//#region src/index.d.ts
|
|
25
|
-
type H3Middleware = Middleware$1 | [Middleware$1, Record<string, any>];
|
|
26
|
-
interface H3DriverOptions {
|
|
27
|
-
bindRouter: (app: H3) => PromiseOrValue<void>;
|
|
28
|
-
mountPublicAssets?: (app: H3, publicPath: string) => PromiseOrValue<void>;
|
|
29
|
-
createApp?: () => H3;
|
|
30
|
-
onError?: (err: Error | string, event: H3Event) => unknown;
|
|
31
|
-
}
|
|
32
|
-
declare class H3EventResponse {
|
|
33
|
-
response: Response;
|
|
34
|
-
status: number;
|
|
35
|
-
statusText?: string;
|
|
36
|
-
constructor(response: Response);
|
|
37
|
-
get headers(): Headers;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* The H3Driver class implements the ArkstackKitDriver contract for the H3 framework.
|
|
41
|
-
*/
|
|
42
|
-
declare class H3Driver extends ArkstackKitDriver<H3, H3Middleware> {
|
|
43
|
-
readonly name = "h3";
|
|
44
|
-
private readonly options;
|
|
45
|
-
/**
|
|
46
|
-
* Creates an instance of H3Driver.
|
|
47
|
-
*
|
|
48
|
-
* @param options
|
|
49
|
-
*/
|
|
50
|
-
constructor(options: H3DriverOptions);
|
|
51
|
-
/**
|
|
52
|
-
* Creates an H3 application instance.
|
|
53
|
-
*
|
|
54
|
-
* @returns
|
|
55
|
-
*/
|
|
56
|
-
createApp(): H3;
|
|
57
|
-
/**
|
|
58
|
-
* Mounts static assets from the specified public path to the H3 application.
|
|
59
|
-
*
|
|
60
|
-
* @param app
|
|
61
|
-
* @param publicPath
|
|
62
|
-
*/
|
|
63
|
-
mountPublicAssets(app: H3, publicPath: string): PromiseOrValue<void>;
|
|
64
|
-
/**
|
|
65
|
-
* Binds the router to the H3 application using the provided bindRouter function.
|
|
66
|
-
*
|
|
67
|
-
* @param app
|
|
68
|
-
*/
|
|
69
|
-
bindRouter(app: H3): PromiseOrValue<void>;
|
|
70
|
-
/**
|
|
71
|
-
* Applies middleware to the H3 application.
|
|
72
|
-
*
|
|
73
|
-
* @param app
|
|
74
|
-
* @param middleware
|
|
75
|
-
*/
|
|
76
|
-
applyMiddleware(app: H3, middleware: H3Middleware | Middleware$2 | MiddlewareConfig): void;
|
|
77
|
-
/**
|
|
78
|
-
* Starts the H3 server on the specified port.
|
|
79
|
-
*
|
|
80
|
-
* The bind host can be overridden with the `APP_HOST` (or `HOST`) env
|
|
81
|
-
* variable. It defaults to `0.0.0.0` so the server is reachable on all
|
|
82
|
-
* network interfaces, which platforms like Railway require for their
|
|
83
|
-
* healthcheck proxy to reach the app.
|
|
84
|
-
*
|
|
85
|
-
* @param app
|
|
86
|
-
* @param port
|
|
87
|
-
*/
|
|
88
|
-
start(app: H3, port: number): void;
|
|
89
|
-
}
|
|
90
|
-
//#endregion
|
|
91
|
-
export { Router$1 as a, H3Middleware as i, H3DriverOptions as n, defaultErrorHandler as o, H3EventResponse as r, H3Driver as t };
|
package/dist/types-DPGHB4nY.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/// <reference path="./app.d.ts" />
|
|
2
|
-
import { ArkstackKitDriver, ArkstackMiddlewareConfig, ArkstackRouteListOptions, PromiseOrValue } from "@arkstack/contract";
|
|
3
|
-
import { H3, H3Event, HTTPError, HTTPResponse, Middleware } from "h3";
|
|
4
|
-
import { Route } from "clear-router";
|
|
5
|
-
import { Router } from "clear-router/h3";
|
|
6
|
-
import { ClassMiddleware } from "clear-router/types/basic";
|
|
7
|
-
import { H3App, Handler, HttpContext, Middleware as Middleware$1 } from "clear-router/types/h3";
|
|
8
|
-
|
|
9
|
-
//#region dist/index-E-098om7.d.ts
|
|
10
|
-
//#endregion
|
|
11
|
-
//#region src/index.d.ts
|
|
12
|
-
type H3Middleware = Middleware$1 | [Middleware$1, Record<string, any>];
|
|
13
|
-
//#endregion
|
|
14
|
-
//#region src/types.d.ts
|
|
15
|
-
type Middleware$2 = Middleware | ClassMiddleware<Middleware>;
|
|
16
|
-
type MiddlewareConfig = ArkstackMiddlewareConfig<Middleware$2> | ArkstackMiddlewareConfig<H3Middleware>;
|
|
17
|
-
//#endregion
|
|
18
|
-
export { MiddlewareConfig as n, Middleware$2 as t };
|