import { createSidecarProxy } from '@@/sidecar/create-proxy'; import { mountPrefix } from '@@/plugins/manifest'; import { manifest } from '../manifest'; // /api/email/* — auth, then forward to officer-email. No routes of its own and no mail knowledge: not a // message, not a folder, not an IMAP or SMTP credential. // // The mail store, the HTTP routes, account CRUD, resync and IMAP validation all used to live in the // platform — ~1,800 lines against a 314-line sidecar, with the sidecar importing BACK into the platform to // reach them. They were moved into the sidecar before this extraction, which is the only reason this file // is twenty lines and the extraction was tractable at all. // // ── The prefix is DERIVED, not written ── // // `createSidecarProxy` strips `prefix.length` characters to build the sidecar path, so a literal // '/api/email' is correct only for a first-party publisher. Published by anyone else this mounts at // `/api/p//email`, and a literal would forward `/alice/email/messages` to a sidecar expecting // `/messages`. `mountPrefix` is the one function allowed to know about provenance. // // A from-scratch mailbox sync holds a proxied request open well past the 60s idle default, hence the // timeout; it applies to the whole prefix because the proxy must not know which routes are slow. const proxy = createSidecarProxy({ name: 'email', prefix: `/api${mountPrefix({ appName: 'email', manifest })}`, timeoutSeconds: 1800, }); export const router = proxy.router;