Bun
Serve the Files gateway from Bun.serve. The gateway's handle(req) is already a Web fetch handler, so it drops straight into a route - no adapter needed.
Bun.serve hands your handler a Web Request and sends back whatever Response you return — which is exactly the shape the gateway speaks (handle(req: Request): Promise<Response>). So there is no files-sdk/bun adapter to import: drop router.handle straight into a route.
import { createFiles } from "files-sdk";
import { s3 } from "files-sdk/s3";
import { createFilesRouter } from "files-sdk/api";
const router = createFilesRouter({
files: createFiles({ adapter: s3({ bucket: "uploads" }) }),
allowedOrigins: ["https://app.example.com"],
authorize: async ({ req }) => {
/* throw to deny, or return a per-user constraint — see /ui/server/authorization */
},
});
Bun.serve({
port: 3000,
routes: {
// A bare handler runs for every method; the gateway dispatches internally
// (GET = download, POST = the JSON verbs, PUT = upload).
"/api/files": (req) => router.handle(req),
},
});See the gateway options for the full configuration and the authorize model for locking it down.
Astro
Mount the Files gateway in an Astro endpoint. createRouteHandler returns { GET, POST, PUT } over the Web Request Astro hands each route - runs on Node and edge adapters.
Deno
Serve the Files gateway from Deno.serve. The gateway is a Web fetch handler, so it drops in with no adapter - import the SDK with the npm specifier.