Local Provider
Server
The local server layer exposes a rich RPC surface for tree reads, uploads, and mutations.
localDriveRouterContract currently defines procedures such as:
getNodeWithChildrengetNodesByParentIdlistTreelistFlatgetFolderParentsgetURLpresignUploadconfirmUploadcreateFolderupdateNodesetReadonlymoveNodearchiveNodesrestoreNodesdeleteNodes
Recommendation
Keep provider-specific policies such as readonly behavior, file serving rules, and preview generation inside the local drive service rather than inside page components.
Practical split
Use contract-first implementation for RPC-style app interactions and
createLocalDriveRouteHandler() for actual file opening.
Recommended implementation shape
const localDriveProcedure = implement(localDriveRouterContract)
.$context<RPCContext<DatabaseSchema, AuthServerOptions>>()
.use(sessionMiddleware);
export const driveRouter = {
getFolderParents: localDriveProcedure.getFolderParents.handler(async ({ input }) =>
drive.getFolderParents(input),
),
};The route handler currently supports:
GET /api/drive/files/:id?variant=:variant&disposition=:dispositionIt will:
- resolve the node
- resolve the asset
- require a session for private assets
- ask the drive service for a short-lived URL
- redirect the browser to that URL
Why this matters
This keeps your UI simple. A file card can just request a Drive URL, while the server decides:
- whether the file exists
- whether the user is allowed to open it
- what variant to return
- whether the backing storage URL should be temporary