@dashkite/lakeshore
v0.0.5
Published
Broadway provider for mock APIs
Downloads
114
Readme
Lakeshore
Broadway provider for mock APIs
Purpose
Lakeshore is a mock provider for Belmont that enables simulated API resources. It allows you to define handlers for URL templates, making it easy to mock complex API behaviors during development or testing.
Installation
Use your favorite package manager to install @dashkite/lakeshore.
Usage
import Providers from "@dashkite/belmont/providers"
import Lakeshore from "@dashkite/lakeshore"
import Resource from "@dashkite/belmont"
# Register Lakeshore for a 'mock' protocol
Providers.add "mock", Lakeshore
# Define a mock resource handler
Lakeshore.register "mock://api/greetings/:name",
get: ({ url, bindings }) ->
{ description: "ok", content: "Hello, #{bindings.name}!" }
# Use the mock resource
resource = await Resource.resolve
template: "mock://api/greetings/:name"
bindings: { name: "World" }
resource.subscribe ({ name, value }) ->
console.log value # Hello, World!
resource.get()Other Resources
Status
Not suitable for production use. Please report bugs and feature requests via the issue tracker.
