Serverpod constructor

Serverpod(
  1. List<String> args,
  2. DatabaseSerializationManager serializationManager,
  3. EndpointDispatch endpoints, {
  4. Directory? serverDirectory,
  5. ServerpodConfig? config,
  6. ServerpodConfig configOverride(
    1. ServerpodConfig
    )?,
  7. AuthenticationHandler? authenticationHandler,
  8. HealthCheckHandler? healthCheckHandler,
  9. HealthConfig? healthConfig,
  10. Headers? httpResponseHeaders,
  11. Headers? httpOptionsResponseHeaders,
  12. SecurityContextConfig? securityContextConfig,
  13. ExperimentalFeatures? experimentalFeatures,
  14. RuntimeParametersListBuilder? runtimeParametersBuilder,
})

Creates a new Serverpod.

Experimental features

Features marked as experimental are new and the API and names may change from one minor release to another.

Implementation

Serverpod(
  List<String> args,
  this.serializationManager,
  this.endpoints, {
  Directory? serverDirectory,
  ServerpodConfig? config,
  ServerpodConfig Function(ServerpodConfig)? configOverride,
  this.authenticationHandler,
  this.healthCheckHandler,
  HealthConfig? healthConfig,
  Headers? httpResponseHeaders,
  Headers? httpOptionsResponseHeaders,
  SecurityContextConfig? securityContextConfig,
  ExperimentalFeatures? experimentalFeatures,
  this.runtimeParametersBuilder,
}) : serverDirectory = Directory(
       p.normalize(p.absolute((serverDirectory ?? Directory.current).path)),
     ),
     httpResponseHeaders = httpResponseHeaders ?? _defaultHttpResponseHeaders,
     httpOptionsResponseHeaders =
         httpOptionsResponseHeaders ?? _defaultHttpOptionsResponseHeaders,
     _configOverride = configOverride,
     _securityContextConfig = securityContextConfig,
     _healthConfig = healthConfig ?? const HealthConfig(),
     _experimental = ExperimentalApi._(
       config: config,
       experimentalFeatures: experimentalFeatures,
     ) {
  try {
    _initializeServerpod(
      args,
      config: config,
    );
  } on ExitException catch (e) {
    // Construction failed - the object is half-initialized so we
    // can't let control return to the caller. Emit the message
    // synchronously and exit before any async drain could return.
    if (e.message.isNotEmpty) {
      stderr.writeln(e.message);
    }
    exit(e.exitCode);
  } catch (e, stackTrace) {
    stderr.writeln('Error initializing Serverpod: $e');
    stderr.writeln(stackTrace);
    exit(1);
  }
}