@deltablab/hono 0.1.0 → 0.1.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.d.ts CHANGED
@@ -3,7 +3,8 @@ import { PaygatePipelineConnectOptions } from '@deltablab/publisher-core';
3
3
  export { GatewayPipelineOptions, PaygatePipelineConnectOptions } from '@deltablab/publisher-core';
4
4
 
5
5
  interface PaygateHonoCloudOptions {
6
- baseUrl: string;
6
+ /** Optional. Defaults to https://paygate.deltab.ai */
7
+ baseUrl?: string;
7
8
  apiKey: string;
8
9
  }
9
10
  /**
package/dist/index.js CHANGED
@@ -5,9 +5,15 @@ import {
5
5
  paygateResultToWebResponse
6
6
  } from "@deltablab/publisher-core";
7
7
  import { PublisherCloudClient } from "@deltablab/publisher-cloud";
8
+ var DEFAULT_PAYGATE_BASE_URL = "https://paygate.deltab.ai";
9
+ function resolveBaseUrl(baseUrl) {
10
+ const normalized = baseUrl?.trim().replace(/\/+$/, "");
11
+ return normalized && normalized.length > 0 ? normalized : DEFAULT_PAYGATE_BASE_URL;
12
+ }
8
13
  function createMiddleware(options) {
14
+ const baseUrl = resolveBaseUrl(options.baseUrl);
9
15
  const publisherCloud = new PublisherCloudClient({
10
- baseUrl: options.baseUrl,
16
+ baseUrl,
11
17
  apiKey: options.apiKey
12
18
  });
13
19
  const pipeline = createGatewayPipelineForPaidRoute(options, options.endpointId, publisherCloud);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { MiddlewareHandler } from \"hono\";\nimport type {\n GatewayPipelineOptions,\n PaygatePipelineConnectOptions,\n} from \"@deltablab/publisher-core\";\nimport {\n createGatewayPipelineForPaidRoute,\n incomingFromWebRequest,\n paygateResultToWebResponse,\n} from \"@deltablab/publisher-core\";\nimport { PublisherCloudClient } from \"@deltablab/publisher-cloud\";\n\nexport interface PaygateHonoCloudOptions {\n baseUrl: string;\n apiKey: string;\n}\n\n/**\n * Connection options used by `createPaygateHono`.\n * Declared as interface (not type alias) to preserve declaration-merging compatibility.\n */\nexport interface CreatePaygateHonoOptions\n extends PaygateHonoCloudOptions,\n PaygatePipelineConnectOptions {}\n\n/** Route-local options used by `createPaygateHono(...)(route)`. */\nexport interface PaygateHonoRouteOptions {\n endpointId: string;\n}\n\n/**\n * Options for one paid route.\n * Declared as interface (not type alias) to preserve declaration-merging compatibility.\n */\nexport interface PaygateHonoOptions\n extends CreatePaygateHonoOptions,\n PaygateHonoRouteOptions {}\n\nfunction createMiddleware(options: PaygateHonoOptions): MiddlewareHandler {\n const publisherCloud = new PublisherCloudClient({\n baseUrl: options.baseUrl,\n apiKey: options.apiKey,\n });\n\n const pipeline = createGatewayPipelineForPaidRoute(options, options.endpointId, publisherCloud);\n\n return async (c, next) => {\n const result = await pipeline.handle(incomingFromWebRequest(c.req.raw));\n\n if (result.kind === \"next\") {\n return next();\n }\n\n return paygateResultToWebResponse(result);\n };\n}\n\n/**\n * Hono middleware for the PayGate paywall. Uses `c.req.raw` so JSON bodies stay\n * available to later handlers (`c.req.json()`).\n */\nexport function paygateHono(options: PaygateHonoOptions): MiddlewareHandler {\n return createMiddleware(options);\n}\n\nexport function createPaygateHono(\n options: CreatePaygateHonoOptions,\n): (route: PaygateHonoRouteOptions) => MiddlewareHandler {\n return ({ endpointId }: PaygateHonoRouteOptions) =>\n createMiddleware({ ...options, endpointId });\n}\n\nexport type { GatewayPipelineOptions, PaygatePipelineConnectOptions };\n"],"mappings":";AAKA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,4BAA4B;AA4BrC,SAAS,iBAAiB,SAAgD;AACxE,QAAM,iBAAiB,IAAI,qBAAqB;AAAA,IAC9C,SAAS,QAAQ;AAAA,IACjB,QAAQ,QAAQ;AAAA,EAClB,CAAC;AAED,QAAM,WAAW,kCAAkC,SAAS,QAAQ,YAAY,cAAc;AAE9F,SAAO,OAAO,GAAG,SAAS;AACxB,UAAM,SAAS,MAAM,SAAS,OAAO,uBAAuB,EAAE,IAAI,GAAG,CAAC;AAEtE,QAAI,OAAO,SAAS,QAAQ;AAC1B,aAAO,KAAK;AAAA,IACd;AAEA,WAAO,2BAA2B,MAAM;AAAA,EAC1C;AACF;AAMO,SAAS,YAAY,SAAgD;AAC1E,SAAO,iBAAiB,OAAO;AACjC;AAEO,SAAS,kBACd,SACuD;AACvD,SAAO,CAAC,EAAE,WAAW,MACnB,iBAAiB,EAAE,GAAG,SAAS,WAAW,CAAC;AAC/C;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { MiddlewareHandler } from \"hono\";\nimport type {\n GatewayPipelineOptions,\n PaygatePipelineConnectOptions,\n} from \"@deltablab/publisher-core\";\nimport {\n createGatewayPipelineForPaidRoute,\n incomingFromWebRequest,\n paygateResultToWebResponse,\n} from \"@deltablab/publisher-core\";\nimport { PublisherCloudClient } from \"@deltablab/publisher-cloud\";\n\nconst DEFAULT_PAYGATE_BASE_URL = \"https://paygate.deltab.ai\";\n\nexport interface PaygateHonoCloudOptions {\n /** Optional. Defaults to https://paygate.deltab.ai */\n baseUrl?: string;\n apiKey: string;\n}\n\n/**\n * Connection options used by `createPaygateHono`.\n * Declared as interface (not type alias) to preserve declaration-merging compatibility.\n */\nexport interface CreatePaygateHonoOptions\n extends PaygateHonoCloudOptions,\n PaygatePipelineConnectOptions {}\n\n/** Route-local options used by `createPaygateHono(...)(route)`. */\nexport interface PaygateHonoRouteOptions {\n endpointId: string;\n}\n\n/**\n * Options for one paid route.\n * Declared as interface (not type alias) to preserve declaration-merging compatibility.\n */\nexport interface PaygateHonoOptions\n extends CreatePaygateHonoOptions,\n PaygateHonoRouteOptions {}\n\nfunction resolveBaseUrl(baseUrl?: string): string {\n const normalized = baseUrl?.trim().replace(/\\/+$/, \"\");\n return normalized && normalized.length > 0 ? normalized : DEFAULT_PAYGATE_BASE_URL;\n}\n\nfunction createMiddleware(options: PaygateHonoOptions): MiddlewareHandler {\n const baseUrl = resolveBaseUrl(options.baseUrl);\n const publisherCloud = new PublisherCloudClient({\n baseUrl,\n apiKey: options.apiKey,\n });\n\n const pipeline = createGatewayPipelineForPaidRoute(options, options.endpointId, publisherCloud);\n\n return async (c, next) => {\n const result = await pipeline.handle(incomingFromWebRequest(c.req.raw));\n\n if (result.kind === \"next\") {\n return next();\n }\n\n return paygateResultToWebResponse(result);\n };\n}\n\n/**\n * Hono middleware for the PayGate paywall. Uses `c.req.raw` so JSON bodies stay\n * available to later handlers (`c.req.json()`).\n */\nexport function paygateHono(options: PaygateHonoOptions): MiddlewareHandler {\n return createMiddleware(options);\n}\n\nexport function createPaygateHono(\n options: CreatePaygateHonoOptions,\n): (route: PaygateHonoRouteOptions) => MiddlewareHandler {\n return ({ endpointId }: PaygateHonoRouteOptions) =>\n createMiddleware({ ...options, endpointId });\n}\n\nexport type { GatewayPipelineOptions, PaygatePipelineConnectOptions };\n"],"mappings":";AAKA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,4BAA4B;AAErC,IAAM,2BAA2B;AA6BjC,SAAS,eAAe,SAA0B;AAChD,QAAM,aAAa,SAAS,KAAK,EAAE,QAAQ,QAAQ,EAAE;AACrD,SAAO,cAAc,WAAW,SAAS,IAAI,aAAa;AAC5D;AAEA,SAAS,iBAAiB,SAAgD;AACxE,QAAM,UAAU,eAAe,QAAQ,OAAO;AAC9C,QAAM,iBAAiB,IAAI,qBAAqB;AAAA,IAC9C;AAAA,IACA,QAAQ,QAAQ;AAAA,EAClB,CAAC;AAED,QAAM,WAAW,kCAAkC,SAAS,QAAQ,YAAY,cAAc;AAE9F,SAAO,OAAO,GAAG,SAAS;AACxB,UAAM,SAAS,MAAM,SAAS,OAAO,uBAAuB,EAAE,IAAI,GAAG,CAAC;AAEtE,QAAI,OAAO,SAAS,QAAQ;AAC1B,aAAO,KAAK;AAAA,IACd;AAEA,WAAO,2BAA2B,MAAM;AAAA,EAC1C;AACF;AAMO,SAAS,YAAY,SAAgD;AAC1E,SAAO,iBAAiB,OAAO;AACjC;AAEO,SAAS,kBACd,SACuD;AACvD,SAAO,CAAC,EAAE,WAAW,MACnB,iBAAiB,EAAE,GAAG,SAAS,WAAW,CAAC;AAC/C;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deltablab/hono",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Hono middleware wiring PayGate GatewayPipeline to your routes.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -28,10 +28,16 @@
28
28
  },
29
29
  "main": "./dist/index.js",
30
30
  "types": "./dist/index.d.ts",
31
+ "scripts": {
32
+ "build": "tsup",
33
+ "prepublishOnly": "pnpm run build",
34
+ "test": "vitest run",
35
+ "test:watch": "vitest"
36
+ },
31
37
  "dependencies": {
32
- "@deltablab/protocol": "0.1.0",
33
- "@deltablab/publisher-core": "0.1.0",
34
- "@deltablab/publisher-cloud": "0.1.0"
38
+ "@deltablab/protocol": "workspace:*",
39
+ "@deltablab/publisher-core": "workspace:*",
40
+ "@deltablab/publisher-cloud": "workspace:*"
35
41
  },
36
42
  "peerDependencies": {
37
43
  "hono": "^4.0.0"
@@ -41,10 +47,5 @@
41
47
  "tsup": "^8.4.0",
42
48
  "typescript": "^5.7.0",
43
49
  "vitest": "^3.1.0"
44
- },
45
- "scripts": {
46
- "build": "tsup",
47
- "test": "vitest run",
48
- "test:watch": "vitest"
49
50
  }
50
- }
51
+ }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 PayGate contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.