Skip to content

Commit 9599702

Browse files
committed
Added a very basic uptime check page.
1 parent f41e4b0 commit 9599702

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright Dave Verwer, Sven A. Schmidt, and other contributors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
import Fluent
16+
import Plot
17+
import Vapor
18+
19+
enum UptimeCheckController {
20+
21+
@Sendable
22+
static func show(req: Request) async throws -> String {
23+
// A package page query is a good test of whether the site is healthy.
24+
let (_, _) = try await API.PackageController.GetRoute
25+
.query(on: req.db,
26+
owner: "SwiftPackageIndex",
27+
repository: "SemanticVersion")
28+
return "Success"
29+
}
30+
}

Sources/App/Core/SiteURL.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ enum SiteURL: Resourceable, Sendable {
134134
case stylesheets(String)
135135
case supporters
136136
case tryInPlayground
137+
case uptimeCheck
137138
case validateSPIManifest
138139

139140
var path: String {
@@ -254,6 +255,9 @@ enum SiteURL: Resourceable, Sendable {
254255
case .tryInPlayground:
255256
return "try-in-a-playground"
256257

258+
case .uptimeCheck:
259+
return "uptime-check"
260+
257261
case .validateSPIManifest:
258262
return "validate-spi-manifest"
259263
}
@@ -276,6 +280,7 @@ enum SiteURL: Resourceable, Sendable {
276280
.siteMapStaticPages,
277281
.supporters,
278282
.tryInPlayground,
283+
.uptimeCheck,
279284
.validateSPIManifest:
280285
return [.init(stringLiteral: path)]
281286

Sources/App/routes.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ func routes(_ app: Application) throws {
128128
app.get(SiteURL.supporters.pathComponents, use: SupportersController.show).excludeFromOpenAPI()
129129
}
130130

131+
do { // Uptime check
132+
app.get(SiteURL.uptimeCheck.pathComponents, use: UptimeCheckController.show).excludeFromOpenAPI()
133+
}
134+
131135
do { // spi.yml validation page
132136
app.get(SiteURL.validateSPIManifest.pathComponents, use: ValidateSPIManifestController.show)
133137
.excludeFromOpenAPI()

0 commit comments

Comments
 (0)