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

Compare commits

...

2 Commits

Author SHA1 Message Date
Francesco Paolo Severino
3bf55dbe84
Merge branch 'main' into readme 2025-03-18 18:03:49 +01: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
3 changed files with 10 additions and 13 deletions

@ -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 AppTests {
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()