Chaqmoq - A server-side web framework in Swift

Swift MIT License Actions Status Codacy Badge Contributing Twitter

Installation

Swift

Download and install Swift

Swift Package

mkdir MyApp
cd MyApp
swift package init --type executable // Creates an executable app named "MyApp"

Package.swift

// swift-tools-version:5.3

import PackageDescription

let package = Package(
    name: "MyApp",
    dependencies: [
        .package(name: "chaqmoq", url: "https://github.com/chaqmoq/chaqmoq.git", .branch("master"))
    ],
    targets: [
        .target(name: "MyApp", dependencies: [
            .product(name: "Chaqmoq", package: "chaqmoq"),
        ]),
        .testTarget(name: "MyAppTests", dependencies: [
            .target(name: "MyApp")
        ])
    ]
)

Build

swift build -c release

Usage

main.swift

import Chaqmoq

let app = Chaqmoq()
app.get { _ in
    "Hello World"
}
try app.run() // Open http://localhost:8080 in a browser

Run

swift run

Tests

swift test --enable-test-discovery --sanitize=thread