factory/infra (0.3.2)
Published 2026-10-09 00:47:49 +00:00 by bmiadmin
Installation
{
"repositories": [{
"type": "composer",
"url": " "
}
]
}composer config repositories.bmiadmin composer composer require factory/infra:0.3.2About this package
SaaS Factory infra: API envelope, pagination, idempotency keys, request-ID logging, health endpoint, rate limits, and the platform's own shapeless surfaces — app feedback and plan/subscription billing.
factory/infra — v0.1.0
Cross-cutting HTTP infrastructure for every product API.
Provides
- Response envelope —
Http\ApiResponse:ok()/paginate()→{ok, data, meta}for collections,item()→ flat JSON for single created/fetched resources (the factory_core client readsid/referencefrom the top level of the POST body — never wrap those),fail()→{ok:false, message, errors}.
- Idempotency —
factory.idempotencymiddleware: caches the response of a successful mutating request perIdempotency-Key(which factory_core sends on every POST) forinfra.idempotency_ttl_hours; retries replay, never double-book. - Request-ID + structured logging —
factory.request-idmiddleware: honours or mintsX-Request-Id, adds it (plus method/path/product) to the log context and the response. - Rate limits — named limiters
factory-api/factory-writes(configinfra.rate_limits, envFACTORY_RATE_API/FACTORY_RATE_WRITES), counted per signed-in person (the kernel's actor ref) and per address only for an anonymous call (0.3.2): behind a carrier NAT, one address is a whole town. It needs sign-in to run before the throttle, which factory/auth'sAuthenticatearranges from 0.6.2. - Health —
GET /api/health→ app, time, db reachability (503 when degraded).
Endpoints
| Method | Path | Purpose |
|---|---|---|
| GET | /api/health | Liveness/readiness for ops + probes |
Config
config/infra.php — rate limits, idempotency TTL. Requires a cache store
(file cache is fine for the blueprint).
Dependencies
Dependencies
| ID | Version |
|---|---|
| factory/kernel | ^0.2 || ^0.3 || ^0.4 || ^0.5 || ^0.6 || ^0.7 || ^0.8 || ^0.9 || ^0.10 |
| illuminate/database | ^10.0 || ^11.0 || ^12.0 || ^13.0 |
| illuminate/http | ^10.0 || ^11.0 || ^12.0 || ^13.0 |
| illuminate/routing | ^10.0 || ^11.0 || ^12.0 || ^13.0 |
| illuminate/support | ^10.0 || ^11.0 || ^12.0 || ^13.0 |
| php | ^8.2 |
Development dependencies
| ID | Version |
|---|---|
| orchestra/testbench | ^8.0 || ^9.0 || ^10.0 || ^11.0 |
| phpunit/phpunit | ^10.1 || ^11.0 || ^12.0 |