Skip to content

0.7.0

Choose a tag to compare

@zaiev zaiev released this 16 Oct 17:05
· 41 commits to main since this release

Resources and rate limits become values read as dependencies, so routes can be made and described before any database exists.

Upgrading

  • Spindle.Zod.module_ → Spindle.Zod.schemas.
  • Spindle_cli.run takes the app itself and (), not a function of env: Spindle_cli.run ~name ~app:(Spindle.App.make routes) (). The Spindle_cli.app type is gone.
  • Rate.create takes no ~mono_clock, so a limit is made at the top level: Spindle.Rate.create ~limit:10 ~per:Mtime.Span.min ().
  • App.start takes the monotonic clock as ~mono_clock; Spindle.serve gives it from its environment. A limit in an app never started answers 500.
  • A limit's counts belong to its app, so two servers or two tests never share a key's count.
  • In tests, Test.app ~mono_clock takes an Eio_mock clock to move; by default the clock never moves.

New

  • Resources: let db = Dep.of_resource "database" names one, let+ pool = db in reads it in a route.
  • Spindle.serve, App.start and Test.app take ~resources:[ Dep.resource db pool ].
  • A route reading a resource the server was not given, or one given twice, stops the server before it listens, naming both.
  • Test.app needs only the resources the called routes read; Test.call raises Invalid_argument on a missing one.
  • The OpenAPI document and Zod schemas never list a resource. Dep.need has a Resource constructor.