@arkstack/driver-h3 0.14.21 → 0.15.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/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as staticAssetHandler } from "./middlewares-
|
|
1
|
+
import { t as staticAssetHandler } from "./middlewares-BORI5o6J.js";
|
|
2
2
|
import { ArkstackKitDriver } from "@arkstack/contract";
|
|
3
3
|
import { H3, HTTPResponse, serve, toResponse } from "h3";
|
|
4
4
|
import { ErrorHandler, Logger, env, renderError, resolveRuntimeModule } from "@arkstack/common";
|
|
@@ -35,6 +35,26 @@ declare class CorsMiddleware {
|
|
|
35
35
|
handler(event: H3Event<EventHandlerRequest>, next: NextFunction): Promise<void>;
|
|
36
36
|
}
|
|
37
37
|
//#endregion
|
|
38
|
+
//#region src/middlewares/inertia.d.ts
|
|
39
|
+
/**
|
|
40
|
+
* Bind the Inertia request context for H3.
|
|
41
|
+
*
|
|
42
|
+
* Normalizes the H3 event into the adapter's driver-agnostic shape and runs the
|
|
43
|
+
* downstream handler inside Inertia's async-local context (mirroring the `resora`
|
|
44
|
+
* middleware), so `inertia()` / `Inertia.*` resolve the active request.
|
|
45
|
+
*
|
|
46
|
+
* It also upgrades a `302` redirect returned for a `PUT`/`PATCH`/`DELETE` Inertia
|
|
47
|
+
* visit to `303 See Other`, which the Inertia client requires to follow the
|
|
48
|
+
* redirect with a `GET`. (Prefer `Inertia.redirect()` / `Inertia.back()`, which
|
|
49
|
+
* already emit the correct status.)
|
|
50
|
+
*
|
|
51
|
+
* `@arkstack/inertia` is imported dynamically so the package stays optional.
|
|
52
|
+
*/
|
|
53
|
+
declare const inertia: () => (event: H3Event, next: NextFunction) => Promise<unknown>;
|
|
54
|
+
declare class InertiaMiddleware {
|
|
55
|
+
handler(event: H3Event, next: NextFunction): Promise<unknown>;
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
38
58
|
//#region src/middlewares/request-logger.d.ts
|
|
39
59
|
/**
|
|
40
60
|
* Middleware to log incoming requests and their response times.
|
|
@@ -71,4 +91,4 @@ declare const resora: () => (event: H3Event, next: NextFunction) => Promise<unkn
|
|
|
71
91
|
//#region src/middlewares/static-asset-handler.d.ts
|
|
72
92
|
declare const staticAssetHandler: (publicPath?: string) => (event: H3Event) => Promise<_$h3.HTTPResponse | undefined> | undefined;
|
|
73
93
|
//#endregion
|
|
74
|
-
export { AuthMiddleware, CorsMiddleware, RequestLoggerMiddleware, auth, cors, requestLogger, resora, staticAssetHandler };
|
|
94
|
+
export { AuthMiddleware, CorsMiddleware, InertiaMiddleware, RequestLoggerMiddleware, auth, cors, inertia, requestLogger, resora, staticAssetHandler };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { AuthMiddleware, CorsMiddleware, RequestLoggerMiddleware, auth, cors, requestLogger, resora, staticAssetHandler };
|
|
1
|
+
import { a as InertiaMiddleware, c as cors, i as requestLogger, l as AuthMiddleware, n as resora, o as inertia, r as RequestLoggerMiddleware, s as CorsMiddleware, t as staticAssetHandler, u as auth } from "../middlewares-BORI5o6J.js";
|
|
2
|
+
export { AuthMiddleware, CorsMiddleware, InertiaMiddleware, RequestLoggerMiddleware, auth, cors, inertia, requestLogger, resora, staticAssetHandler };
|
|
@@ -273,6 +273,43 @@ var CorsMiddleware = class {
|
|
|
273
273
|
}
|
|
274
274
|
};
|
|
275
275
|
//#endregion
|
|
276
|
+
//#region src/middlewares/inertia.ts
|
|
277
|
+
/**
|
|
278
|
+
* Bind the Inertia request context for H3.
|
|
279
|
+
*
|
|
280
|
+
* Normalizes the H3 event into the adapter's driver-agnostic shape and runs the
|
|
281
|
+
* downstream handler inside Inertia's async-local context (mirroring the `resora`
|
|
282
|
+
* middleware), so `inertia()` / `Inertia.*` resolve the active request.
|
|
283
|
+
*
|
|
284
|
+
* It also upgrades a `302` redirect returned for a `PUT`/`PATCH`/`DELETE` Inertia
|
|
285
|
+
* visit to `303 See Other`, which the Inertia client requires to follow the
|
|
286
|
+
* redirect with a `GET`. (Prefer `Inertia.redirect()` / `Inertia.back()`, which
|
|
287
|
+
* already emit the correct status.)
|
|
288
|
+
*
|
|
289
|
+
* `@arkstack/inertia` is imported dynamically so the package stays optional.
|
|
290
|
+
*/
|
|
291
|
+
const inertia = () => {
|
|
292
|
+
return async (event, next) => {
|
|
293
|
+
const { runInertia, shouldUpgradeRedirect } = await import("@arkstack/inertia");
|
|
294
|
+
const sourceUrl = event.req._url ? event.req._url.pathname + event.req._url.search : event.req.url || "/";
|
|
295
|
+
const request = {
|
|
296
|
+
method: String(event.req.method ?? "GET").toUpperCase(),
|
|
297
|
+
url: sourceUrl,
|
|
298
|
+
header: (name) => event.req.headers.get(name) ?? void 0
|
|
299
|
+
};
|
|
300
|
+
return runInertia(request, async () => {
|
|
301
|
+
const result = await next();
|
|
302
|
+
if (request.header("x-inertia") === "true" && result && typeof result === "object" && typeof result.statusCode === "number" && shouldUpgradeRedirect(request.method, result.statusCode)) result.statusCode = 303;
|
|
303
|
+
return result;
|
|
304
|
+
});
|
|
305
|
+
};
|
|
306
|
+
};
|
|
307
|
+
var InertiaMiddleware = class {
|
|
308
|
+
handler(event, next) {
|
|
309
|
+
return inertia()(event, next);
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
//#endregion
|
|
276
313
|
//#region src/middlewares/request-logger.ts
|
|
277
314
|
const colors = {
|
|
278
315
|
GET: "green",
|
|
@@ -372,4 +409,4 @@ const staticAssetHandler = (publicPath = "public") => {
|
|
|
372
409
|
};
|
|
373
410
|
};
|
|
374
411
|
//#endregion
|
|
375
|
-
export {
|
|
412
|
+
export { InertiaMiddleware as a, cors as c, requestLogger as i, AuthMiddleware as l, resora as n, inertia as o, RequestLoggerMiddleware as r, CorsMiddleware as s, staticAssetHandler as t, auth as u };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkstack/driver-h3",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
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,20 +38,24 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@ngrok/ngrok": "^1.7.0",
|
|
41
|
-
"@resora/plugin-clear-router": "^1.0.
|
|
42
|
-
"clear-router": "^2.
|
|
41
|
+
"@resora/plugin-clear-router": "^1.0.66",
|
|
42
|
+
"clear-router": "^2.9.0",
|
|
43
43
|
"resora": "^1.3.27",
|
|
44
|
-
"@arkstack/contract": "^0.
|
|
44
|
+
"@arkstack/contract": "^0.15.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"h3": "2.0.1-rc.22",
|
|
48
|
-
"@arkstack/
|
|
49
|
-
"@arkstack/foundry": "^0.
|
|
50
|
-
"@arkstack/
|
|
48
|
+
"@arkstack/auth": "^0.15.0",
|
|
49
|
+
"@arkstack/foundry": "^0.15.0",
|
|
50
|
+
"@arkstack/inertia": "^0.15.0",
|
|
51
|
+
"@arkstack/common": "^0.15.0"
|
|
51
52
|
},
|
|
52
53
|
"peerDependenciesMeta": {
|
|
53
54
|
"@arkstack/auth": {
|
|
54
55
|
"optional": true
|
|
56
|
+
},
|
|
57
|
+
"@arkstack/inertia": {
|
|
58
|
+
"optional": true
|
|
55
59
|
}
|
|
56
60
|
},
|
|
57
61
|
"scripts": {
|