Skip to content

swift-foundations/swift-server-foundation

Repository files navigation

swift-server-foundation

Status

W3-SHELL (TEMPORARY). swift-server-foundation is dissolved (decomposition W3, 2026-07-14). This package survives as a marked re-export shell ONLY so existing manifests and the app resolve unchanged until the E-program app cutover. Do not add new consumers.

Former concern New home
\.date + Date.Generator (C1) swift-clocks-dependencies
\.httpClient (C2) deleted — dead code (de-engine R3)
\.mainEventLoopGroup (C3) swift-event-loop-group-dependencies
console logger handler (C4) swift-logger-handlers Logger.Handler.Console
InMemoryStore TTL cache (C5) swift-time-to-live Store.InMemory
URL.canonical (C6) swift-uri RFC_3986.URI.canonical(host:)
Path constants (C7) swift-url-routing compat surface
EnvVars + \.envVars/\.projectRoot (C8) swift-environment-dependencies
throttling × dependencies (C9) swift-throttling-dependencies
translating seam swift-translating-dependencies

A foundation library for server-side Swift development that consolidates essential packages for building server applications.

Overview

swift-server-foundation provides a unified interface to commonly-used server development packages. Instead of managing multiple dependencies individually, this foundation package re-exports and integrates type safety, authentication, infrastructure, and utility libraries into a single import.

Features

  • Type-safe domain models for email addresses, domains, and JWT
  • Password validation with customizable security policies
  • Cryptographic operations via Apple's Crypto framework
  • Rate limiting and request throttling
  • HTTP client with async/await support
  • Structured logging with Apple's unified logging API
  • Environment variable handling with type safety
  • URL routing with internationalization support
  • Declarative content builders

Installation

Add swift-server-foundation to your Package.swift dependencies:

dependencies: [
    .package(url: "https://github.com/coenttb/swift-server-foundation.git", from: "0.0.1")
]

Quick Start

Import the foundation to access all included packages:

import ServerFoundation

// Logging
let logger = Logger(label: "com.example.app")

// HTTP Client
let client = HTTPClient(eventLoopGroupProvider: .shared(eventLoopGroup))

// JWT
let jwt = try JWT(
    payload: ["user_id": "12345"],
    signedBy: key
)

Usage

Type Safety & Domain Modeling

Security

  • Crypto - Cryptographic operations and key management
  • Throttling - Rate limiting for API protection

Server Infrastructure

Configuration

  • EnvironmentVariables - Type-safe environment variable handling
  • ServerFoundationEnvVars - Environment-specific configuration

Date & Time

Routing & Localization

Utilities

Environment Variables

The ServerFoundationEnvVars module provides type-safe access to environment configuration:

import ServerFoundationEnvVars

// Access with defaults
let port = EnvVars.PORT.value ?? 8080

// Require value (throws if missing)
let apiKey = try EnvVars.API_KEY.require()

Related Packages

Dependencies

Used By

Third-Party Dependencies

License

This project is licensed under the Apache 2.0 License. See LICENSE for details.

Contributing

Contributions are welcome. Please open an issue or submit a pull request on GitHub.

Releases

Sponsor this project

Contributors

Languages