CreateStorageRouteHandlersOptions
CreateStorageRouteHandlersOptions<
T> =object
Defined in: packages/storage/src/route-handlers.ts:25
Options for createStorageRouteHandlers.
Type Parameters
Section titled “Type Parameters”T extends StorageSchema
Properties
Section titled “Properties”basePath?
Section titled “basePath?”
optionalbasePath:string
Defined in: packages/storage/src/route-handlers.ts:53
Base path the routes are mounted at. Defaults to "uploads". Must
match the basePath passed to storageRoutes so that signed
URLs resolve to the correct routes.
getEnv()?
Section titled “getEnv()?”
optionalgetEnv: (request) =>Record<string,unknown>
Defined in: packages/storage/src/route-handlers.ts:35
Callback that returns the Workers environment for a given request.
Defaults to reading (request as any).context?.env, which works with
the @cfast/core request adapter. Override this if your runtime exposes
env bindings somewhere else.
Parameters
Section titled “Parameters”request
Section titled “request”Request
Returns
Section titled “Returns”Record<string, unknown>
requireUser()?
Section titled “requireUser()?”
optionalrequireUser: (request) =>Promise<StorageRouteUser> |StorageRouteUser
Defined in: packages/storage/src/route-handlers.ts:47
Authentication gate. Called on both GET (proxy) and POST (upload)
requests before any R2 interaction. Return the authenticated user or
throw a Response to abort. If omitted, the routes run unauthenticated
— only do this if the downstream ownerCheck or signed-token check is
sufficient for your threat model.
On GET requests, if requireUser is omitted and the request carries a
?token=... query parameter, the token is validated against
STORAGE_SECRET instead of calling requireUser.
Parameters
Section titled “Parameters”request
Section titled “request”Request
Returns
Section titled “Returns”Promise<StorageRouteUser> | StorageRouteUser
storage
Section titled “storage”storage:
StorageInstance<T>
Defined in: packages/storage/src/route-handlers.ts:27
The storage instance returned from defineStorage.