start method
Starts a standalone OmnyHub hosting the API on host:port.
Implementation
Future<void> start() async {
final corsMiddleware = this.corsMiddleware();
final server = OmnyHub(
transports: [
if (securityContext == null)
HttpTransport.http(address: host, port: port)
else
HttpTransport.https(
address: host,
port: port,
tls: StaticTls.context(securityContext!),
),
],
middleware: buildMiddleware(),
// Outside the error mapper and authentication — see [corsMiddleware].
outerMiddleware: [?corsMiddleware],
);
for (final service in buildServices()) {
await server.registerService(
service,
// Only the /api/v1 surface is token-gated; /healthz, /metrics and the
// OpenAPI document stay open.
authenticator: service.name == apiServiceName ? _tokenAuth() : null,
);
}
await server.start();
_server = server;
}