defineSpryConfig function

void defineSpryConfig({
  1. String? host,
  2. int? port,
  3. BuildTarget? target,
  4. String? routesDir,
  5. String? middlewareDir,
  6. String? publicDir,
  7. String? outputDir,
  8. bool? caseSensitive,
  9. int? handlerCacheCapacity,
  10. ReloadStrategy? reload,
  11. String? wranglerConfig,
  12. OpenAPIConfig? openapi,
  13. ClientConfig? client,
})

Emits Spry build configuration as JSON for spry.config.dart.

Implementation

void defineSpryConfig({
  /// Overrides the host used by `spry serve`.
  String? host,

  /// Overrides the port used by `spry serve`.
  int? port,

  /// Selects the target runtime.
  BuildTarget? target,

  /// Overrides the routes directory.
  String? routesDir,

  /// Overrides the middleware directory.
  String? middlewareDir,

  /// Overrides the public asset directory.
  String? publicDir,

  /// Overrides the generated output directory.
  String? outputDir,

  /// Controls whether generated routing is case-sensitive.
  bool? caseSensitive,

  /// Sets the LRU cache capacity used for generated handler lookups.
  int? handlerCacheCapacity,

  /// Overrides the reload strategy used by `spry serve`.
  ReloadStrategy? reload,

  /// Overrides the Wrangler config path for Cloudflare targets.
  String? wranglerConfig,

  /// Enables OpenAPI document generation.
  OpenAPIConfig? openapi,

  /// Enables Spry client generation.
  ClientConfig? client,
}) {
  final config = <String, dynamic>{
    'host': ?host,
    'port': ?port,
    'target': ?target?.name,
    'routesDir': ?routesDir,
    'middlewareDir': ?middlewareDir,
    'publicDir': ?publicDir,
    'outputDir': ?outputDir,
    'caseSensitive': ?caseSensitive,
    'handlerCacheCapacity': ?handlerCacheCapacity,
    'reload': ?reload?.name,
    'wranglerConfig': ?wranglerConfig,
    'openapi': ?openapi,
    'client': ?client,
  };

  stdout.writeln(json.encode(config));
}