English | 日本語
Build an HTTP server in Swift whose application code names no web framework.
- No framework in your signatures — Vapor is imported internally and never appears in the public API, so application code compiles and tests without it
- Contract-driven routing — mount an
APIServiceand its endpoints register in one call, with inputs decoded and authentication enforced from the contract - Handlers return values, not responses — an
Encodablereturn is JSON-encoded with ISO 8601 dates - Middleware for CORS, authentication and errors — included, and extensible with your own
- Server-Sent Events and webhooks — stream an
AsyncSequence, or take a delivery's headers and raw bytes - Strict concurrency — every public type is
Sendable
import APIServer
let server = try await Server.create()
server.get("health") {
["status": "healthy"]
}
server.use(CORSServerMiddleware())
server.useErrorMiddleware()
try await server.run()API reference and guides — including getting started, middleware, authentication, and the architecture behind the abstraction.
Add the package to your Package.swift:
dependencies: [
.package(url: "https://github.com/no-problem-dev/swift-api-server.git", from: "3.0.0")
]Then add the product to your target:
.target(
name: "YourTarget",
dependencies: [
.product(name: "APIServer", package: "swift-api-server")
]
)| APIServer | Swift | Platforms |
|---|---|---|
| 2.x | 6.0+ | macOS 14+ · Linux |
MIT. See LICENSE.