@ortha/server-platform-bootstrap
v0.0.4
Published
Creates, configures, and starts a Fastify server instance. Registers all provided plugins sequentially before binding the port. This is the entry point for the Ortha server application.
Readme
@ortha/server-platform-bootstrap
Creates, configures, and starts a Fastify server instance. Registers all provided plugins sequentially before binding the port. This is the entry point for the Ortha server application.
Installation
Internal monorepo dependency — import directly:
import { bootstrap } from '@ortha/server-platform-bootstrap';
import type {
BootstrapConfig,
ServerPlugin
} from '@ortha/server-platform-bootstrap';Usage
import { bootstrap } from '@ortha/server-platform-bootstrap';
import { databasePlugin } from '@ortha/server-platform-database';
import { identityServerPlugin } from '@ortha/server-identity';
import { projectsServerPlugin } from '@ortha/server-projects';
await bootstrap({
config: {
host: '0.0.0.0',
port: 4000,
logLevel: 'info'
},
plugins: [
databasePlugin({ ...dbConfig, schemas: [identitySchema] }),
identityServerPlugin(jwtConfig),
projectsServerPlugin()
]
});Bootstrap Flow
bootstrap({ config, plugins? })- Create Fastify — instance with Pino logger and querystring parser.
- Set error handler — global error handler using
buildErrorResponse()from@ortha/server-utils. - Register sensible —
@fastify/sensiblefor HTTP error helpers. - Register plugins — all provided plugins registered sequentially.
- Listen — call
app.listen()with configured host and port.
API Reference
| Export | Kind | Description |
| ----------------- | -------- | ---------------------------------------------------- |
| bootstrap() | function | Creates Fastify, registers plugins, starts listening |
| BootstrapConfig | type | Server config — logLevel, host, port |
| ServerPlugin | type | Alias for FastifyPluginAsync |
BootstrapConfig
| Property | Type | Description |
| ---------- | -------- | ------------------------------------------ |
| host | string | Server bind address (e.g. '0.0.0.0') |
| port | number | Server bind port (e.g. 4000) |
| logLevel | string | Pino log level ('info', 'debug', etc.) |
Internal Structure
src/lib/
├── types/index.ts # BootstrapConfig, ServerPlugin types
└── bootstrap.ts # Bootstrap functionDependencies
@ortha/server-utils— error response builder@fastify/sensible— HTTP error helpers
Building
nx build server-platform-bootstrap