opacacms 0.1.9 → 0.1.10

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/api.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  createGlobalHandlers,
5
5
  createHandlers,
6
6
  hydrateDoc
7
- } from "./chunk-hmhcense.js";
7
+ } from "./chunk-0nf7fe26.js";
8
8
  import {
9
9
  defineConfig
10
10
  } from "./chunk-zvwb67nd.js";
@@ -14,6 +14,7 @@ import {
14
14
  init_system_schema
15
15
  } from "./chunk-ybbbqj63.js";
16
16
  import {
17
+ __require,
17
18
  __toCommonJS
18
19
  } from "./chunk-8sqjbsgt.js";
19
20
 
@@ -1000,7 +1001,6 @@ function createDatabaseInitMiddleware(config, state) {
1000
1001
  }
1001
1002
 
1002
1003
  // src/server/middlewares/rate-limit.ts
1003
- import { WorkersKVStore } from "@hono-rate-limiter/cloudflare";
1004
1004
  import { rateLimiter } from "hono-rate-limiter";
1005
1005
  function createRateLimitMiddleware(config) {
1006
1006
  const rateLimitConfig = config.api?.rateLimit;
@@ -1028,7 +1028,12 @@ function createRateLimitMiddleware(config) {
1028
1028
  if (!resolvedStore && c.env) {
1029
1029
  const kvBindingKey = Object.keys(c.env).find((key) => key.startsWith("OPACA_") && c.env[key]?.put && c.env[key]?.get);
1030
1030
  if (kvBindingKey) {
1031
- resolvedStore = new WorkersKVStore({ namespace: c.env[kvBindingKey] });
1031
+ try {
1032
+ const { WorkersKVStore } = await import("@hono-rate-limiter/cloudflare");
1033
+ resolvedStore = new WorkersKVStore({ namespace: c.env[kvBindingKey] });
1034
+ } catch (e) {
1035
+ logger.error("Failed to load @hono-rate-limiter/cloudflare dynamic import. Make sure you are in a Cloudflare environment.", e);
1036
+ }
1032
1037
  }
1033
1038
  }
1034
1039
  const limiter = rateLimiter({
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createAPIRouter
3
- } from "../chunk-hmhcense.js";
3
+ } from "../chunk-0nf7fe26.js";
4
4
  import"../chunk-dy5t83hr.js";
5
5
  import"../chunk-62ev8gnc.js";
6
6
  import"../chunk-cvdd4eqh.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createAPIRouter
3
- } from "../chunk-hmhcense.js";
3
+ } from "../chunk-0nf7fe26.js";
4
4
  import"../chunk-dy5t83hr.js";
5
5
  import"../chunk-62ev8gnc.js";
6
6
  import"../chunk-cvdd4eqh.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createAPIRouter
3
- } from "../chunk-hmhcense.js";
3
+ } from "../chunk-0nf7fe26.js";
4
4
  import"../chunk-dy5t83hr.js";
5
5
  import"../chunk-62ev8gnc.js";
6
6
  import"../chunk-cvdd4eqh.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createAPIRouter
3
- } from "../chunk-hmhcense.js";
3
+ } from "../chunk-0nf7fe26.js";
4
4
  import"../chunk-dy5t83hr.js";
5
5
  import"../chunk-62ev8gnc.js";
6
6
  import"../chunk-cvdd4eqh.js";
@@ -1,3 +1,3 @@
1
1
  import type { MiddlewareHandler } from "hono";
2
- import type { OpacaConfig } from "../../types";
2
+ import type { OpacaConfig } from "@/types";
3
3
  export declare function createRateLimitMiddleware(config: OpacaConfig): MiddlewareHandler;
package/dist/server.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  createGlobalHandlers,
5
5
  createHandlers,
6
6
  hydrateDoc
7
- } from "./chunk-hmhcense.js";
7
+ } from "./chunk-0nf7fe26.js";
8
8
  import {
9
9
  defineConfig
10
10
  } from "./chunk-zvwb67nd.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opacacms",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "scripts": {
5
5
  "build": "bun run ../../scripts/build.ts && tsc --emitDeclarationOnly",
6
6
  "build:publish": "bun run ../../scripts/build.ts --publish && tsc --emitDeclarationOnly",
@@ -1,7 +1,8 @@
1
- import { WorkersKVStore } from "@hono-rate-limiter/cloudflare";
1
+
2
2
  import type { Context, MiddlewareHandler } from "hono";
3
3
  import { rateLimiter } from "hono-rate-limiter";
4
- import type { OpacaConfig } from "../../types";
4
+ import type { OpacaConfig } from "@/types";
5
+ import { logger } from "@/utils/logger";
5
6
 
6
7
  export function createRateLimitMiddleware(config: OpacaConfig): MiddlewareHandler {
7
8
  const rateLimitConfig = config.api?.rateLimit;
@@ -50,7 +51,12 @@ export function createRateLimitMiddleware(config: OpacaConfig): MiddlewareHandle
50
51
  );
51
52
 
52
53
  if (kvBindingKey) {
53
- resolvedStore = new WorkersKVStore({ namespace: (c.env as any)[kvBindingKey] });
54
+ try {
55
+ const { WorkersKVStore } = await import("@hono-rate-limiter/cloudflare");
56
+ resolvedStore = new WorkersKVStore({ namespace: (c.env as any)[kvBindingKey] });
57
+ } catch (e) {
58
+ logger.error("Failed to load @hono-rate-limiter/cloudflare dynamic import. Make sure you are in a Cloudflare environment.", e);
59
+ }
54
60
  }
55
61
  }
56
62