Tulip Logo IconTulip
Local Provider

Server

The local server layer exposes a rich RPC surface for tree reads, uploads, and mutations.

localDriveRouterContract currently defines procedures such as:

  • getNodeWithChildren
  • getNodesByParentId
  • listTree
  • listFlat
  • getFolderParents
  • getURL
  • presignUpload
  • confirmUpload
  • createFolder
  • updateNode
  • setReadonly
  • moveNode
  • archiveNodes
  • restoreNodes
  • deleteNodes

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.

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=:disposition

It will:

  1. resolve the node
  2. resolve the asset
  3. require a session for private assets
  4. ask the drive service for a short-lived URL
  5. 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

On this page