factory/infra (0.3.1)

Published 2026-08-16 13:47:50 +00:00 by bmiadmin

Installation

{
	"repositories": [{
			"type": "composer",
			"url": ""
		}
	]
}
composer require factory/infra:0.3.1

About 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 reads id/reference from the top level of the POST body — never wrap those),
    • fail() → {ok:false, message, errors}.
  • Idempotency — factory.idempotency middleware: caches the response of a successful mutating request per Idempotency-Key (which factory_core sends on every POST) for infra.idempotency_ttl_hours; retries replay, never double-book.
  • Request-ID + structured logging — factory.request-id middleware: honours or mints X-Request-Id, adds it (plus method/path/product) to the log context and the response.
  • Rate limits — named limiters factory-api / factory-writes (config infra.rate_limits, env FACTORY_RATE_API / FACTORY_RATE_WRITES).
  • 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
Details
Composer
2026-08-16 13:47:50 +00:00
32
proprietary
30 KiB
Assets (1)
Versions (3) View all
0.3.1 2026-08-16
0.3.0 2026-08-14
0.2.1 2026-08-06