Elysia
Mount the Files gateway in an Elysia app. Web-native on Bun - forward the raw Request with parse:'none' so the gateway reads the body itself.
Elysia is Web-native (it runs on Bun), so the handler context carries the raw request and the gateway consumes it directly — ({ request }) => router.handle(request). Register it with all so all three methods reach the gateway: it dispatches on the method internally (GET = download, POST = the JSON verbs, PUT = upload).
import { Elysia } from "elysia";
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 */
},
});
const app = new Elysia()
// `parse: "none"` keeps Elysia from consuming the body the gateway must read.
.all("/api/files", ({ request }) => router.handle(request), { parse: "none" })
.listen(3000);
See the gateway options for the full configuration and the authorize model for locking it down.