@donkeylabs/server 1.1.2 → 1.1.4

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/server.ts +12 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@donkeylabs/server",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "type": "module",
5
5
  "description": "Type-safe plugin system for building RPC-style APIs with Bun",
6
6
  "main": "./src/index.ts",
package/src/server.ts CHANGED
@@ -780,14 +780,23 @@ ${factoryFunction}
780
780
  return this.handleSSE(req, ip);
781
781
  }
782
782
 
783
- // We only allow POST for RPC routes
784
- if (req.method !== "POST") return new Response("Method Not Allowed", { status: 405 });
785
-
786
783
  // Extract action from URL path (e.g., "auth.login")
787
784
  const actionName = url.pathname.slice(1);
788
785
 
789
786
  const route = this.routeMap.get(actionName);
790
787
  if (route) {
788
+ const handlerType = route.handler || "typed";
789
+
790
+ // Handlers that accept GET requests (for browser compatibility)
791
+ const getEnabledHandlers = ["stream", "sse", "html", "raw"];
792
+
793
+ // Check method based on handler type
794
+ if (req.method === "GET" && !getEnabledHandlers.includes(handlerType)) {
795
+ return new Response("Method Not Allowed", { status: 405 });
796
+ }
797
+ if (req.method !== "GET" && req.method !== "POST") {
798
+ return new Response("Method Not Allowed", { status: 405 });
799
+ }
791
800
  const type = route.handler || "typed";
792
801
 
793
802
  // First check core handlers