Project updates from Template #1

Merged
javier merged 123 commits from project/update-from-template into main 2026-09-04 13:40:36 +00:00
15 changed files with 26 additions and 42 deletions
Showing only changes of commit a868275347 - Show all commits
@@ -15,8 +15,8 @@
buildForAnalyzing = "YES"> buildForAnalyzing = "YES">
<BuildableReference <BuildableReference
BuildableIdentifier = "primary" BuildableIdentifier = "primary"
BlueprintIdentifier = "Web" BlueprintIdentifier = "Infrastructure"
BuildableName = "Web" BuildableName = "Infrastructure"
ReferencedContainer = "container:"> ReferencedContainer = "container:">
</BuildableReference> </BuildableReference>
</BuildActionEntry> </BuildActionEntry>
@@ -33,8 +33,8 @@
skipped = "NO"> skipped = "NO">
<BuildableReference <BuildableReference
BuildableIdentifier = "primary" BuildableIdentifier = "primary"
BlueprintIdentifier = "WebTests" BlueprintIdentifier = "InfrastructureTests"
BuildableName = "WebTests" BuildableName = "InfrastructureTests"
ReferencedContainer = "container:"> ReferencedContainer = "container:">
</BuildableReference> </BuildableReference>
</TestableReference> </TestableReference>
@@ -61,8 +61,8 @@
<MacroExpansion> <MacroExpansion>
<BuildableReference <BuildableReference
BuildableIdentifier = "primary" BuildableIdentifier = "primary"
BlueprintIdentifier = "Web" BlueprintIdentifier = "Infrastructure"
BuildableName = "Web" BuildableName = "Infrastructure"
ReferencedContainer = "container:"> ReferencedContainer = "container:">
</BuildableReference> </BuildableReference>
</MacroExpansion> </MacroExpansion>
@@ -3,15 +3,15 @@
import PackageDescription import PackageDescription
let package = Package( let package = Package(
name: "Web", name: "Infrastructure",
platforms: [ platforms: [
.macOS(.v15), .macOS(.v15),
], ],
products: [ products: [
.library( .library(
name: "Web", name: "Infrastructure",
targets: [ targets: [
"Web" "Infrastructure"
] ]
), ),
], ],
@@ -23,7 +23,7 @@ let package = Package(
], ],
targets: [ targets: [
.target( .target(
name: "Web", name: "Infrastructure",
dependencies: [ dependencies: [
.product( .product(
name: "Hummingbird", name: "Hummingbird",
@@ -33,9 +33,9 @@ let package = Package(
path: "Sources" path: "Sources"
), ),
.testTarget( .testTarget(
name: "WebTests", name: "InfrastructureTests",
dependencies: [ dependencies: [
.byName(name: "Web"), .byName(name: "Infrastructure"),
.product( .product(
name: "HummingbirdTesting", name: "HummingbirdTesting",
package: "hummingbird" package: "hummingbird"
@@ -3,7 +3,7 @@ import HummingbirdTesting
import NIOCore import NIOCore
import Testing import Testing
@testable import Web @testable import Infrastructure
@Suite("addController method") @Suite("addController method")
struct RouterMethodsTests { struct RouterMethodsTests {
@@ -1,5 +1,5 @@
import Hummingbird import Hummingbird
import Web import Infrastructure
/// A controller serving its path back as plain text, used to observe route registration. /// A controller serving its path back as plain text, used to observe route registration.
struct StubController { struct StubController {
+2 -2
View File
@@ -49,7 +49,7 @@ WORKDIR /build
# a relative path, so its manifest must be present for resolution to succeed. # a relative path, so its manifest must be present for resolution to succeed.
COPY ./Packages/Localization/Package.swift ./Packages/Localization/ COPY ./Packages/Localization/Package.swift ./Packages/Localization/
COPY ./Packages/Persistence/Package.swift ./Packages/Persistence/ COPY ./Packages/Persistence/Package.swift ./Packages/Persistence/
COPY ./Packages/Web/Package.swift ./Packages/Web/ COPY ./Packages/Infrastructure/Package.swift ./Packages/Infrastructure/
COPY ./Services/Website/Package.swift ./Services/Website/Package.resolved ./Services/Website/ COPY ./Services/Website/Package.swift ./Services/Website/Package.resolved ./Services/Website/
RUN swift package --package-path ./Services/Website resolve RUN swift package --package-path ./Services/Website resolve
@@ -57,7 +57,7 @@ RUN swift package --package-path ./Services/Website resolve
# in the assets stage and copied into staging after the binary is produced. # in the assets stage and copied into staging after the binary is produced.
COPY ./Packages/Localization/Sources ./Packages/Localization/Sources COPY ./Packages/Localization/Sources ./Packages/Localization/Sources
COPY ./Packages/Persistence/Sources ./Packages/Persistence/Sources COPY ./Packages/Persistence/Sources ./Packages/Persistence/Sources
COPY ./Packages/Web/Sources ./Packages/Web/Sources COPY ./Packages/Infrastructure/Sources ./Packages/Infrastructure/Sources
COPY ./Services/Website/Sources ./Services/Website/Sources COPY ./Services/Website/Sources ./Services/Website/Sources
COPY ./Services/Website/Tests ./Services/Website/Tests COPY ./Services/Website/Tests ./Services/Website/Tests
+3 -3
View File
@@ -27,7 +27,7 @@ let package = Package(
path: "../../Packages/Persistence" path: "../../Packages/Persistence"
), ),
.package( .package(
path: "../../Packages/Web" path: "../../Packages/Infrastructure"
), ),
.package( .package(
url: "https://github.com/elementary-swift/elementary.git", url: "https://github.com/elementary-swift/elementary.git",
@@ -80,7 +80,7 @@ let package = Package(
dependencies: [ dependencies: [
.byName(name: "Localization"), .byName(name: "Localization"),
.byName(name: "Persistence"), .byName(name: "Persistence"),
.byName(name: "Web"), .byName(name: "Infrastructure"),
.product( .product(
name: "Configuration", name: "Configuration",
package: "swift-configuration" package: "swift-configuration"
@@ -120,7 +120,7 @@ let package = Package(
name: "WebsiteLibraryTests", name: "WebsiteLibraryTests",
dependencies: [ dependencies: [
.byName(name: "Persistence"), .byName(name: "Persistence"),
.byName(name: "Web"), .byName(name: "Infrastructure"),
.byName(name: "WebsiteLibrary"), .byName(name: "WebsiteLibrary"),
.product( .product(
name: "Elementary", name: "Elementary",
+1 -1
View File
@@ -26,7 +26,7 @@ Two SwiftPM targets:
The `Website` executable depends on three local packages: The `Website` executable depends on three local packages:
- `Localization` (`Packages/Localization`) — the `Localize` and `Negotiate` helpers and the `LanguageList` of catalog languages (used by `WebsiteLibrary`). - `Localization` (`Packages/Localization`) — the `Localize` and `Negotiate` helpers and the `LanguageList` of catalog languages (used by `WebsiteLibrary`).
- `Web` (`Packages/Web`) — the `RouterController` protocol the controllers conform to and the `addController` result-builder extension that registers their routes on the router declaratively. - `Infrastructure` (`Packages/Infrastructure`) — the `RouterController` protocol the controllers conform to and the `addController` result-builder extension that registers their routes on the router declaratively.
- `Persistence` (`Packages/Persistence`) — the Fluent-based data layer: the `Driver` selector, the `Service` factory that builds the `Fluent` service, the `PrepareDB` registrar that declares the migrations, and the `Probe` consulted by the readiness check; the models, migrations, and repositories stay internal to the package. It has no dependency on `swift-configuration`; the executable maps the `database.*` keys onto the driver. - `Persistence` (`Packages/Persistence`) — the Fluent-based data layer: the `Driver` selector, the `Service` factory that builds the `Fluent` service, the `PrepareDB` registrar that declares the migrations, and the `Probe` consulted by the readiness check; the models, migrations, and repositories stay internal to the package. It has no dependency on `swift-configuration`; the executable maps the `database.*` keys onto the driver.
The persistence backend runs as a `Fluent` service inside the application's ServiceLifecycle group, so it starts and stops alongside the HTTP server (which owns its connection-pool shutdown on graceful termination). The persistence backend runs as a `Fluent` service inside the application's ServiceLifecycle group, so it starts and stops alongside the HTTP server (which owns its connection-pool shutdown on graceful termination).
@@ -3,7 +3,7 @@ import Hummingbird
import HummingbirdCompression import HummingbirdCompression
import Logging import Logging
import Persistence import Persistence
import Web import Infrastructure
import WebsiteLibrary import WebsiteLibrary
/// Builds the website application. /// Builds the website application.
@@ -1,7 +1,7 @@
import Hummingbird import Hummingbird
import NIOCore import NIOCore
import Persistence import Persistence
import Web import Infrastructure
/// Serves the website's health-check routes. /// Serves the website's health-check routes.
/// ///
@@ -1,5 +1,5 @@
import Hummingbird import Hummingbird
import Web import Infrastructure
/// Serves the website's root routes. /// Serves the website's root routes.
/// ///
-16
View File
@@ -48,22 +48,6 @@ struct AppTests {
} }
} }
@Test
func `landing page to answer a head request`() async throws {
try await app(
staticFilesPath: staticFilesPath
).test(.router) { client in
try await client.execute(
uri: "/",
method: .head
) { response in
#expect(response.status == .ok)
#expect(response.headers[.contentType] == "text/html; charset=utf-8")
#expect(response.body.readableBytes == 0)
}
}
}
@Test @Test
func `health check to be served at the health path`() async throws { func `health check to be served at the health path`() async throws {
try await app( try await app(
+3 -3
View File
@@ -48,9 +48,9 @@
}, },
{ {
"target" : { "target" : {
"containerPath" : "container:..\/..\/Packages\/Web", "containerPath" : "container:..\/..\/Packages\/Infrastructure",
"identifier" : "WebTests", "identifier" : "InfrastructureTests",
"name" : "WebTests" "name" : "InfrastructureTests"
} }
} }
], ],