Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ concurrency:
jobs:
analyze:
name: Analyze
runs-on: macos-15
runs-on: macos-26
permissions:
security-events: write

Expand All @@ -35,7 +35,6 @@ jobs:

- name: Build
run: swift build

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4

2 changes: 1 addition & 1 deletion .github/workflows/docc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: macos-15
runs-on: macos-26

steps:
- name: Checkout 🛎️
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Select Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: "16.3.0"
xcode-version: latest-stable

- name: Install SwiftLint
run: brew install swiftlint
Expand All @@ -26,4 +26,4 @@ jobs:
run: swiftlint version

- name: Run SwiftLint
run: swiftlint --strict --config .swiftlint.yml
run: swiftlint --config .swiftlint.yml
20 changes: 14 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Select Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: "16.3.0"
xcode-version: latest-stable
- name: Cache SwiftPM
uses: actions/cache@v4
with:
Expand All @@ -38,14 +38,22 @@ jobs:
${{ runner.os }}-spm-
- name: Build
run: swift build -v
- name: Test (parallel)
run: swift test -v --parallel
- name: Run tests
run: swift test -v --enable-code-coverage
- name: Fetch Coverage
id: coverage-files
uses: sersoft-gmbh/swift-coverage-action@v4
- name: Publish Coverage to Codecov
uses: codecov/codecov-action@v4.0.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ${{ steps.coverage-files.outputs.files }}
# =========================
# Linux
# =========================
linux:
runs-on: ubuntu-latest
container: swift:6.0-jammy
container: swift:6.2-jammy
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -58,5 +66,5 @@ jobs:
linux-spm-
- name: Build
run: swift build -v
- name: Test (parallel)
run: swift test -v --parallel
- name: Run tests
run: swift test
6 changes: 3 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// swift-tools-version: 6.0
// swift-tools-version: 6.2
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "fs-error-middleware",
platforms: [
.macOS(.v13)
.macOS(.v15)
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
Expand All @@ -17,7 +17,7 @@ let package = Package(
],
dependencies: [
// 💧 A server-side Swift web framework.
.package(url: "https://github.com/vapor/vapor.git", from: "4.115.0"),
.package(url: "https://github.com/vapor/vapor.git", from: "4.120.0"),
// 📄 Swift-DocC plugin for generating documentation.
.package(url: "https://github.com/apple/swift-docc-plugin.git", from: "1.0.0"),
],
Expand Down
6 changes: 1 addition & 5 deletions Sources/ErrorMiddleware/ErrorMiddleware.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ import Foundation
/// Extension for ErrorMiddleware.
public extension ErrorMiddleware {
/// Creates a custom `ErrorMiddleware` for handling errors in a Vapor application.
///
/// This function provides a tailored error handling mechanism based on the application's environment
/// and an additional numeric identifier. It categorizes errors into specific cases, assigns appropriate
/// HTTP status codes, and generates error responses in JSON format.
///
///
/// - Parameters:
/// - environment: The current `Environment` of the application, used to determine error visibility and debugging details.
/// - number: An additional numeric identifier to uniquely identify error codes.
Expand Down
11 changes: 11 additions & 0 deletions Tests/ErrorMiddlewareTests/ErrorMiddlewareTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@ struct ErrorMiddlewareTests {
}
try await app.asyncShutdown()
}

@Test("Error middleware success")
func errorMiddlewareSuccess() async throws {
try await withApp { app in
app.middleware.use(ErrorMiddleware.custom(environment: app.environment, for: 1))

try await app.test(.POST, "order") { res throws in
#expect(res.status == .ok)
}
}
}

@Test("Error middleware snake case")
func errorMiddlewareSnakeCase() async throws {
Expand Down
Loading