1
0
mirror of https://github.com/vapor/template.git synced 2025-05-15 18:23:20 +08:00

Compare commits

...

6 Commits

Author SHA1 Message Date
Tim Condon
3c1e20e228
Merge branch 'main' into dynamic-target-name 2025-03-18 16:38:31 +00:00
Francesco Paolo Severino
7605eb3491
Update template for new Toolbox ()
* Update for new Toolbox rendering

* Try fixing AppTests

* Try fixing configure.swift
2025-03-18 16:37:21 +00:00
Francesco Paolo Severino
45c24b320c
Merge branch 'main' into dynamic-target-name 2025-03-18 14:12:01 +01:00
Francesco Paolo Severino
b36c0ef752
Add recommended VS Code extensions ()
* Add recommended VS Code extensions

* Add `extensions.json` to `manifest.yml`
2025-03-18 12:36:21 +00:00
Francesco Paolo Severino
0fa0788056
Merge branch 'main' into dynamic-target-name 2025-03-18 11:03:13 +01:00
Tim Condon
c1f81a18a9
Update template for Swift 6 () 2025-03-18 08:20:32 +00:00
9 changed files with 22 additions and 22 deletions

3
.gitignore vendored

@ -8,5 +8,4 @@ db.sqlite
.swiftpm
.env
.env.*
!.env.example
.vscode
!.env.example

3
.vscode/extensions.json vendored Normal file

@ -0,0 +1,3 @@
{
"recommendations": ["swiftlang.swift-vscode", "Vapor.vapor-vscode"]
}

@ -39,11 +39,9 @@ let package = Package(
],
swiftSettings: swiftSettings
)
],
swiftLanguageModes: [.v5]
]
)
var swiftSettings: [SwiftSetting] { [
.enableUpcomingFeature("DisableOutwardActorInference"),
.enableExperimentalFeature("StrictConcurrency"),
.enableUpcomingFeature("ExistentialAny"),
] }

@ -2,7 +2,7 @@ import Fluent
import Vapor
struct TodoController: RouteCollection {
func boot(routes: RoutesBuilder) throws {
func boot(routes: any RoutesBuilder) throws {
let todos = routes.grouped("todos")
todos.get(use: self.index)

@ -1,14 +1,14 @@
import Fluent
struct CreateTodo: AsyncMigration {
func prepare(on database: Database) async throws {
func prepare(on database: any Database) async throws {
try await database.schema("todos")
.id()
.field("title", .string, .required)
.create()
}
func revert(on database: Database) async throws {
func revert(on database: any Database) async throws {
try await database.schema("todos").delete()
}
}

@ -16,19 +16,17 @@ public func configure(_ app: Application) async throws {
password: Environment.get("DATABASE_PASSWORD") ?? "vapor_password",
database: Environment.get("DATABASE_NAME") ?? "vapor_database",
tls: .prefer(try .init(configuration: .clientDefault)))
), as: .psql){{/fluent.db.is_postgres}}{{#fluent.db.is_mysql}} app.databases.use(DatabaseConfigurationFactory.mysql(
), as: .psql){{/fluent.db.is_postgres}}{{#fluent.db.is_mysql}}app.databases.use(DatabaseConfigurationFactory.mysql(
hostname: Environment.get("DATABASE_HOST") ?? "localhost",
port: Environment.get("DATABASE_PORT").flatMap(Int.init(_:)) ?? MySQLConfiguration.ianaPortNumber,
username: Environment.get("DATABASE_USERNAME") ?? "vapor_username",
password: Environment.get("DATABASE_PASSWORD") ?? "vapor_password",
database: Environment.get("DATABASE_NAME") ?? "vapor_database"
), as: .mysql){{/fluent.db.is_mysql}}{{#fluent.db.is_sqlite}} app.databases.use(DatabaseConfigurationFactory.sqlite(.file("db.sqlite")), as: .sqlite){{/fluent.db.is_sqlite}}
), as: .mysql){{/fluent.db.is_mysql}}{{#fluent.db.is_sqlite}}app.databases.use(DatabaseConfigurationFactory.sqlite(.file("db.sqlite")), as: .sqlite){{/fluent.db.is_sqlite}}
app.migrations.add(CreateTodo()){{/fluent}}{{#leaf}}
app.views.use(.leaf)
{{/leaf}}
app.views.use(.leaf){{/leaf}}
// register routes
try routes(app)

@ -4,7 +4,7 @@
func routes(_ app: Application) throws {
{{#leaf}}app.get { req async throws in
try await req.view.render("index", ["title": "Hello Vapor!"])
}{{/leaf}}{{^leaf}} app.get { req async in
}{{/leaf}}{{^leaf}}app.get { req async in
"It works!"
}{{/leaf}}

@ -11,14 +11,13 @@ struct {{name}}Tests {
private func withApp(_ test: (Application) async throws -> ()) async throws {
let app = try await Application.make(.testing)
do {
try await configure(app)
{{#fluent}}try await app.autoMigrate()
{{/fluent}} try await test(app)
{{#fluent}}try await app.autoRevert()
{{/fluent}} }
catch {
try await configure(app){{#fluent}}
try await app.autoMigrate(){{/fluent}}
try await test(app){{#fluent}}
try await app.autoRevert(){{/fluent}}
} catch {
{{#fluent}}try? await app.autoRevert()
{{/fluent}} try await app.asyncShutdown()
{{/fluent}}try await app.asyncShutdown()
throw error
}
try await app.asyncShutdown()

@ -91,3 +91,6 @@ files:
dynamic: true
- .gitignore
- .dockerignore
- folder: .vscode
files:
- extensions.json