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.
Deno.serve calls your handler with a Web Request and returns your Response — the exact shape the gateway speaks (handle(req: Request): Promise<Response>). There is no files-sdk/deno adapter: pass router.handle the request directly. Import the SDK over Deno’s npm: specifier (or an import map).
import { createFiles } from "npm:files-sdk";
import { s3 } from "npm:files-sdk/s3";
import { createFilesRouter } from "npm: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 */
},
});
Deno.serve({ port: 3000 }, (req) => {
const { pathname } = new URL(req.url);
// One path, every method — the gateway dispatches internally
// (GET = download, POST = the JSON verbs, PUT = upload).
if (pathname === "/api/files") {
return router.handle(req);
}
return new Response("Not Found", { status: 404 });
});
See the gateway options for the full configuration and the authorize model for locking it down.