Compare commits

..

2 Commits

Author SHA1 Message Date
Christoph Hagen
32055ecdec Change default server path 2023-12-21 08:50:52 +01:00
Christoph Hagen
dabc94b8b5 Detect production environment 2023-12-21 08:50:28 +01:00
4 changed files with 5 additions and 15 deletions

View File

@ -8,7 +8,7 @@
If the server runs under https://example.com/schafkopf If the server runs under https://example.com/schafkopf
then apiPath = "/schafkopf" then apiPath = "/schafkopf"
*/ */
const apiPath = "/schafkopf" const apiPath = ""
var useEnglishTexts = false var useEnglishTexts = false

View File

@ -1,6 +1,5 @@
{ {
"serverPort": 8000, "serverPort": 8000,
"production": false,
"mail": { "mail": {
"serverDomain": "https://example.com/schafkopf", "serverDomain": "https://example.com/schafkopf",
"emailHostname": "example.com", "emailHostname": "example.com",

View File

@ -6,13 +6,6 @@ struct Configuration {
let mail: EMail? let mail: EMail?
/**
Use a database file and reduce logging.
If this property is set to `false`, then an in-memory database is used with increased logging.
*/
let production: Bool
struct EMail { struct EMail {
/// The url to the root of the server /// The url to the root of the server

View File

@ -33,19 +33,17 @@ func configure(_ app: Application) async throws {
app.http.server.configuration.port = configuration.serverPort app.http.server.configuration.port = configuration.serverPort
// Set target environment switch app.environment {
app.environment = .production case .production:
if !configuration.production {
app.logger.logLevel = .info
log("[DEVELOPMENT] Using in-memory database") log("[DEVELOPMENT] Using in-memory database")
app.databases.use(.sqlite(.memory), as: .sqlite) app.databases.use(.sqlite(.memory), as: .sqlite)
} else { default:
app.logger.logLevel = .notice app.logger.logLevel = .notice
let dbFile = storageFolder.appendingPathComponent("db.sqlite").path let dbFile = storageFolder.appendingPathComponent("db.sqlite").path
log("[PRODUCTION] Using database at \(dbFile)") log("[PRODUCTION] Using database at \(dbFile)")
app.databases.use(.sqlite(.file(dbFile)), as: .sqlite) app.databases.use(.sqlite(.file(dbFile)), as: .sqlite)
} }
app.migrations.add(UserTableMigration()) app.migrations.add(UserTableMigration())
app.migrations.add(PasswordResetMigration()) app.migrations.add(PasswordResetMigration())