Runtime services
Identity
Section titled “Identity”Generated packages/api/mailer.ts, runtime.ts, boot.ts, and loadApp()
options; dataPath() and databasePath() from @sapporta/server.
Contract
Section titled “Contract”createSapportaMailer()returns the Nodemailer transport, parsed defaults, andsendMail()helper.- Boot constructs the database connection and mailer, then passes them to
loadApp(). openProjectRuntime()openssqlite.dbin the directory named bySAPPORTA_DATA_DIRand returns that file’s path asdatabasePath. Boot prints it after the ready line.- Health policy accepts
public,authenticated, ordisabled. - Boot owns process signal handling, server close, transport close, and database cleanup.
Data directory paths
Section titled “Data directory paths”dataPath(...segments) joins path segments onto the data directory.
databasePath() returns dataPath("sqlite.db"). Use dataPath() for an
application’s own files that belong with its database, so a process pointed at
another data directory also reads another copy of them:
import { dataPath } from "@sapporta/server";
const importPresetsFile = dataPath("user-config", "import-presets.json");- An absolute
SAPPORTA_DATA_DIRis used as given. A relative one resolves against the project root, the directory withsapporta.json, never against the working directory. - Both functions throw when
SAPPORTA_DATA_DIRis unset or empty. - Both work at the top of a module and from any working directory, including
code that runs before
openProjectRuntime()sets the project root. Until then,projectRoot()walks up forsapporta.jsonfrom the script that started the process, such aspackages/api/dist/boot.js, and then from the working directory. @sapporta/server/data-direxports the same two functions and depends on nothing beyond Node built-ins.drizzle.config.tsimportsdatabasePath()from it, so Drizzle Kit opens the database the app opens.