@decocms/runtime 1.0.0-alpha.30 → 1.0.0-alpha.32
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/package.json +5 -2
- package/src/asset-server/index.ts +13 -1
- package/src/index.ts +3 -0
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decocms/runtime",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.32",
|
|
4
4
|
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"check": "tsc --noEmit"
|
|
7
|
+
},
|
|
5
8
|
"dependencies": {
|
|
6
9
|
"@cloudflare/workers-types": "^4.20250617.0",
|
|
7
|
-
"@deco/mcp": "npm:@jsr/deco__mcp@0.
|
|
10
|
+
"@deco/mcp": "npm:@jsr/deco__mcp@0.7.8",
|
|
8
11
|
"@decocms/bindings": "1.0.1-alpha.17",
|
|
9
12
|
"@modelcontextprotocol/sdk": "1.20.2",
|
|
10
13
|
"@ai-sdk/provider": "^2.0.0",
|
|
@@ -6,11 +6,21 @@ import { Handler } from "hono/types";
|
|
|
6
6
|
interface AssetServerConfig {
|
|
7
7
|
env: "development" | "production" | "test";
|
|
8
8
|
localDevProxyUrl?: string | URL;
|
|
9
|
+
/**
|
|
10
|
+
* The prefix to use for serving the assets.
|
|
11
|
+
* Default: "/assets/*"
|
|
12
|
+
*/
|
|
13
|
+
assetsMiddlewarePath?: string;
|
|
14
|
+
/**
|
|
15
|
+
* The directory to serve the assets from.
|
|
16
|
+
* Default: "./dist/client"
|
|
17
|
+
*/
|
|
9
18
|
assetsDirectory?: string;
|
|
10
19
|
}
|
|
11
20
|
|
|
12
21
|
const DEFAULT_LOCAL_DEV_PROXY_URL = "http://localhost:4000";
|
|
13
22
|
const DEFAULT_ASSETS_DIRECTORY = "./dist/client";
|
|
23
|
+
const DEFAULT_ASSETS_MIDDLEWARE_PATH = "/assets/*";
|
|
14
24
|
|
|
15
25
|
interface HonoApp {
|
|
16
26
|
use: (path: string, handler: Handler) => void;
|
|
@@ -25,11 +35,13 @@ export const applyAssetServerRoutes = (
|
|
|
25
35
|
const localDevProxyUrl =
|
|
26
36
|
config.localDevProxyUrl ?? DEFAULT_LOCAL_DEV_PROXY_URL;
|
|
27
37
|
const assetsDirectory = config.assetsDirectory ?? DEFAULT_ASSETS_DIRECTORY;
|
|
38
|
+
const assetsMiddlewarePath =
|
|
39
|
+
config.assetsMiddlewarePath ?? DEFAULT_ASSETS_MIDDLEWARE_PATH;
|
|
28
40
|
|
|
29
41
|
if (environment === "development") {
|
|
30
42
|
app.use("*", devServerProxy(localDevProxyUrl));
|
|
31
43
|
} else if (environment === "production") {
|
|
32
|
-
app.use(
|
|
44
|
+
app.use(assetsMiddlewarePath, serveStatic({ root: assetsDirectory }));
|
|
33
45
|
app.get("*", serveStatic({ path: `${assetsDirectory}/index.html` }));
|
|
34
46
|
}
|
|
35
47
|
};
|
package/src/index.ts
CHANGED
|
@@ -308,6 +308,9 @@ export const withRuntime = <TEnv, TSchema extends z.ZodTypeAny = never>(
|
|
|
308
308
|
|
|
309
309
|
// MCP endpoint
|
|
310
310
|
if (url.pathname === "/mcp") {
|
|
311
|
+
if (req.method === "GET") {
|
|
312
|
+
return new Response("Method not allowed", { status: 405 });
|
|
313
|
+
}
|
|
311
314
|
// If OAuth is configured, require authentication
|
|
312
315
|
if (oauthHandlers && !oauthHandlers.hasAuth(req)) {
|
|
313
316
|
// Clone request to check method without consuming the original body
|