@arkstack/driver-h3 0.12.10 → 0.12.12

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.
@@ -1,10 +1,13 @@
1
- import { i as H3Middleware } from "../index-CDLqKB-5.js";
1
+ import { i as H3Middleware } from "../index-BLhGjrmA.js";
2
2
  import * as _$h3 from "h3";
3
- import { H3Event } from "h3";
3
+ import { EventHandlerRequest, H3Event } from "h3";
4
4
  import { NextFunction } from "clear-router/types/h3";
5
5
 
6
6
  //#region src/middlewares/auth.d.ts
7
7
  declare const auth: (event: H3Event, next: () => unknown | Promise<unknown>) => Promise<unknown>;
8
+ declare class AuthMiddleware {
9
+ handler(event: H3Event, next: () => unknown | Promise<unknown>): Promise<unknown>;
10
+ }
8
11
  //#endregion
9
12
  //#region src/middlewares/cors.d.ts
10
13
  declare const cors: (options?: {
@@ -17,6 +20,20 @@ declare const cors: (options?: {
17
20
  optionsSuccessStatus?: number;
18
21
  preflightContinue?: boolean;
19
22
  }) => (event: H3Event, next: NextFunction) => Promise<void>;
23
+ declare class CorsMiddleware {
24
+ private options;
25
+ constructor(options?: {
26
+ origin?: string | string[] | RegExp | boolean;
27
+ methods?: string[] | string;
28
+ allowedHeaders?: string[] | string | null;
29
+ exposedHeaders?: string[] | string;
30
+ credentials?: boolean;
31
+ maxAge?: number | string;
32
+ optionsSuccessStatus?: number;
33
+ preflightContinue?: boolean;
34
+ });
35
+ handler(event: H3Event<EventHandlerRequest>, next: NextFunction): Promise<void>;
36
+ }
20
37
  //#endregion
21
38
  //#region src/middlewares/request-logger.d.ts
22
39
  /**
@@ -31,8 +48,15 @@ declare const requestLogger: ({
31
48
  }?: {
32
49
  allowInProduction?: boolean;
33
50
  }) => H3Middleware;
51
+ declare class RequestLoggerMiddleware {
52
+ private options;
53
+ constructor(options?: {
54
+ allowInProduction?: boolean;
55
+ });
56
+ handler(): H3Middleware;
57
+ }
34
58
  //#endregion
35
59
  //#region src/middlewares/static-asset-handler.d.ts
36
60
  declare const staticAssetHandler: (publicPath?: string) => (event: H3Event) => Promise<_$h3.HTTPResponse | undefined> | undefined;
37
61
  //#endregion
38
- export { auth, cors, requestLogger, staticAssetHandler };
62
+ export { AuthMiddleware, CorsMiddleware, RequestLoggerMiddleware, auth, cors, requestLogger, staticAssetHandler };
@@ -1,2 +1,2 @@
1
- import { i as auth, n as requestLogger, r as cors, t as staticAssetHandler } from "../middlewares-DWmfAXws.js";
2
- export { auth, cors, requestLogger, staticAssetHandler };
1
+ import { a as cors, i as CorsMiddleware, n as RequestLoggerMiddleware, o as AuthMiddleware, r as requestLogger, s as auth, t as staticAssetHandler } from "../middlewares-CGBJHsH7.js";
2
+ export { AuthMiddleware, CorsMiddleware, RequestLoggerMiddleware, auth, cors, requestLogger, staticAssetHandler };
@@ -1,9 +1,9 @@
1
1
  import { Arkstack } from "@arkstack/contract";
2
2
  import { serveStatic } from "h3";
3
3
  import { Logger, nodeEnv } from "@arkstack/common";
4
- import { Hook } from "@arkstack/foundry";
5
4
  import { join, resolve } from "node:path";
6
5
  import { readFile, stat } from "node:fs/promises";
6
+ import { Hook } from "@arkstack/foundry";
7
7
  //#region src/middlewares/auth.ts
8
8
  const auth = async (event, next) => {
9
9
  const { Auth, AuthenticationException } = await import("@arkstack/auth");
@@ -44,6 +44,11 @@ const auth = async (event, next) => {
44
44
  throw error;
45
45
  }
46
46
  };
47
+ var AuthMiddleware = class {
48
+ handler(event, next) {
49
+ return auth(event, next);
50
+ }
51
+ };
47
52
  const readBearerToken = (authorization) => {
48
53
  if (!authorization?.startsWith("Bearer ")) return null;
49
54
  return authorization.substring(7);
@@ -257,6 +262,15 @@ const cors = (options = {}) => async (event, next) => {
257
262
  next();
258
263
  }
259
264
  };
265
+ var CorsMiddleware = class {
266
+ options;
267
+ constructor(options = {}) {
268
+ this.options = options;
269
+ }
270
+ handler(event, next) {
271
+ return cors(this.options).call(this.handler, event, next);
272
+ }
273
+ };
260
274
  //#endregion
261
275
  //#region src/middlewares/request-logger.ts
262
276
  const colors = {
@@ -288,6 +302,15 @@ const requestLogger = ({ allowInProduction = false } = {}) => async (event, next
288
302
  [`- ${duration}ms`, "dim"]
289
303
  ], " ");
290
304
  };
305
+ var RequestLoggerMiddleware = class {
306
+ options;
307
+ constructor(options = {}) {
308
+ this.options = options;
309
+ }
310
+ handler() {
311
+ return requestLogger(this.options);
312
+ }
313
+ };
291
314
  //#endregion
292
315
  //#region src/middlewares/static-asset-handler.ts
293
316
  const staticAssetHandler = (publicPath = "public") => {
@@ -316,4 +339,4 @@ const staticAssetHandler = (publicPath = "public") => {
316
339
  };
317
340
  };
318
341
  //#endregion
319
- export { auth as i, requestLogger as n, cors as r, staticAssetHandler as t };
342
+ export { cors as a, CorsMiddleware as i, RequestLoggerMiddleware as n, AuthMiddleware as o, requestLogger as r, auth as s, staticAssetHandler as t };
@@ -0,0 +1,18 @@
1
+ /// <reference path="./app.d.ts" />
2
+ import { ArkstackKitDriver, ArkstackMiddlewareConfig, ArkstackRouteListOptions, PromiseOrValue } from "@arkstack/contract";
3
+ import { H3, H3Event, HTTPError, 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-Dls9g_8I.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 };
@@ -0,0 +1,10 @@
1
+ import { ArkstackMiddlewareConfig } from "@arkstack/contract";
2
+ import { Middleware } from "h3";
3
+ import { ClassMiddleware } from "clear-router/types/basic";
4
+ import { H3Middleware } from "@arkstack/driver-h3";
5
+
6
+ //#region src/types.d.ts
7
+ type Middleware$1 = Middleware | ClassMiddleware<Middleware>;
8
+ type MiddlewareConfig = ArkstackMiddlewareConfig<Middleware$1> | ArkstackMiddlewareConfig<H3Middleware>;
9
+ //#endregion
10
+ export { MiddlewareConfig as n, Middleware$1 as t };
package/dist/types.d.ts CHANGED
@@ -1,16 +1,2 @@
1
- /// <reference path="./app.d.ts" />
2
- import { ArkstackKitDriver, ArkstackMiddlewareConfig, ArkstackRouteListOptions, PromiseOrValue } from "@arkstack/contract";
3
- import { H3, H3Event, HTTPError, HTTPResponse } from "h3";
4
- import { Router } from "clear-router/h3";
5
- import { H3App, Handler, HttpContext, Middleware } from "clear-router/types/h3";
6
- import { Route } from "clear-router";
7
-
8
- //#region dist/index-CDLqKB-5.d.ts
9
- //#endregion
10
- //#region src/index.d.ts
11
- type H3Middleware = Middleware | [Middleware, Record<string, any>];
12
- //#endregion
13
- //#region src/types.d.ts
14
- type MiddlewareConfig = ArkstackMiddlewareConfig<H3Middleware>;
15
- //#endregion
16
- export { MiddlewareConfig };
1
+ import { n as MiddlewareConfig, t as Middleware } from "./types-C4wkZQOC.js";
2
+ export { Middleware, MiddlewareConfig };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkstack/driver-h3",
3
- "version": "0.12.10",
3
+ "version": "0.12.12",
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",
@@ -40,13 +40,13 @@
40
40
  "clear-router": "^2.8.6",
41
41
  "@resora/plugin-clear-router": "^1.0.37",
42
42
  "resora": "^1.3.6",
43
- "@arkstack/contract": "^0.12.10"
43
+ "@arkstack/contract": "^0.12.12"
44
44
  },
45
45
  "peerDependencies": {
46
46
  "h3": "2.0.1-rc.22",
47
- "@arkstack/auth": "^0.12.10",
48
- "@arkstack/common": "^0.12.10",
49
- "@arkstack/foundry": "^0.12.10"
47
+ "@arkstack/foundry": "^0.12.12",
48
+ "@arkstack/auth": "^0.12.12",
49
+ "@arkstack/common": "^0.12.12"
50
50
  },
51
51
  "peerDependenciesMeta": {
52
52
  "@arkstack/auth": {