Compare commits

..

No commits in common. "32055ecdec1d89f20d9aa71dd125eccde0070b57" and "a08dc4f175b27422366ccb9e82dee23a8ccd84ad" have entirely different histories.

4 changed files with 15 additions and 5 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 = "" const apiPath = "/schafkopf"
var useEnglishTexts = false var useEnglishTexts = false

View File

@ -1,5 +1,6 @@
{ {
"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,6 +6,13 @@ 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,17 +33,19 @@ func configure(_ app: Application) async throws {
app.http.server.configuration.port = configuration.serverPort app.http.server.configuration.port = configuration.serverPort
switch app.environment { // Set target environment
case .production: app.environment = .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)
default: } else {
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())