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
then apiPath = "/schafkopf"
*/
const apiPath = "/schafkopf"
const apiPath = ""
var useEnglishTexts = false

View File

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

View File

@ -6,13 +6,6 @@ struct Configuration {
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 {
/// 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
// Set target environment
app.environment = .production
if !configuration.production {
app.logger.logLevel = .info
switch app.environment {
case .production:
log("[DEVELOPMENT] Using in-memory database")
app.databases.use(.sqlite(.memory), as: .sqlite)
} else {
default:
app.logger.logLevel = .notice
let dbFile = storageFolder.appendingPathComponent("db.sqlite").path
log("[PRODUCTION] Using database at \(dbFile)")
app.databases.use(.sqlite(.file(dbFile)), as: .sqlite)
}
app.migrations.add(UserTableMigration())
app.migrations.add(PasswordResetMigration())