Pass your runtime config to defineApiConfig. It returns a resolved config with convenience methods. Call startServer() to run the full HTTP server.
1
2
3
4
5
6
7
8
9
10
11
12
import { defineApiConfig } from "@lakeql/api/config"
const server = defineApiConfig({
runtime,
tokenResolver,
permissions,
baseDir: import.meta.dirname,
schemaPath: "./schemas",
})
await server.startServer()
The Runtime #
The API server does not build the runtime. Your application builds it with createLakeQLRuntime and passes it in as runtime. Resolvers reach read strategies through it. This keeps the API out of the runtime lifecycle, so your code owns shutdown.
Graceful Shutdown #
Because the application owns the runtime, close it on shutdown signals:
1
2
3
4
5
6
7
const shutdown = async () => {
await runtime.close()
process.exit(0)
}
process.on("SIGTERM", shutdown)
process.on("SIGINT", shutdown)
Lower-Level Entry Points #
Need the Yoga instance without starting an HTTP listener? defineApiConfig also exposes createYogaServer(logger). For direct use, the package exports createApiServer and startApiServer.