Skip to content

Repository files navigation

APIServer

English | 日本語

Build an HTTP server in Swift whose application code names no web framework.

Swift 6.0+ macOS 14+ License

Features

  • 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 APIService and its endpoints register in one call, with inputs decoded and authentication enforced from the contract
  • Handlers return values, not responses — an Encodable return 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

Quick Start

import APIServer

let server = try await Server.create()

server.get("health") {
    ["status": "healthy"]
}

server.use(CORSServerMiddleware())
server.useErrorMiddleware()

try await server.run()

Documentation

API reference and guides — including getting started, middleware, authentication, and the architecture behind the abstraction.

Installation

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")
    ]
)

Requirements

APIServer Swift Platforms
2.x 6.0+ macOS 14+ · Linux

License

MIT. See LICENSE.

About

Protocol-based abstraction layer over Vapor — type-safe routing via APIContract, middleware, and Swift 6 strict concurrency

Topics

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages