Reorganize many root config parameters

This commit is contained in:
Alice Gaudon 2021-06-01 14:38:53 +02:00
parent 7ccd335649
commit 0f415144dc
7 changed files with 44 additions and 42 deletions

View File

@ -1,19 +1,39 @@
{
asset_cache: false,
gitlab_webhook_token: 'default',
app: {
listen_addr: '127.0.0.1',
port: 4899,
public_url: "http://localhost:4899",
public_websocket_url: "ws://localhost:4899",
name: 'Example App',
contact_email: 'contact@example.net',
display_email_warning: true,
},
auth: {
// Registered accounts need to be approved by an administrator
approval_mode: false,
// 30 days
name_change_wait_period: 2592000000,
},
log: {
level: "DEBUG",
verbose: true,
db_level: "ERROR",
},
public_url: "http://localhost:4899",
public_websocket_url: "ws://localhost:4899",
listen_addr: '127.0.0.1',
port: 4899,
gitlab_webhook_token: 'default',
magic_link: {
validity_period: 20,
},
mail: {
host: "127.0.0.1",
port: "1025",
secure: false,
username: "",
password: "",
allow_invalid_tls: true,
from: 'contact@example.net',
from_name: 'Example App',
},
mysql: {
connectionLimit: 10,
host: "localhost",
@ -35,28 +55,8 @@
maxAge: 31557600000,
},
},
mail: {
host: "127.0.0.1",
port: "1025",
secure: false,
username: "",
password: "",
allow_invalid_tls: true,
from: 'contact@example.net',
from_name: 'Example App',
},
view: {
cache: false,
dev: true,
},
asset_cache: false,
magic_link: {
validity_period: 20,
},
auth: {
// Registered accounts need to be approved by an administrator
approval_mode: false,
// 30 days
name_change_wait_period: 2592000000,
},
}

View File

@ -1,26 +1,28 @@
{
asset_cache: true,
app: {
public_url: "https://swaf.example",
public_websocket_url: "wss://swaf.example",
},
log: {
level: "DEV",
verbose: false,
db_level: "ERROR",
},
public_url: "https://swaf.example",
public_websocket_url: "wss://swaf.example",
session: {
cookie: {
secure: true,
},
magic_link: {
validity_period: 900,
},
mail: {
secure: true,
allow_invalid_tls: false,
},
magic_link: {
validity_period: 900,
session: {
cookie: {
secure: true,
},
},
view: {
cache: true,
dev: false,
},
asset_cache: true,
}
}

View File

@ -1,4 +1,7 @@
{
auth: {
approval_mode: true,
},
mysql: {
host: "localhost",
user: "root",
@ -12,7 +15,4 @@
maxAge: 1000,
},
},
auth: {
approval_mode: true,
},
}

View File

@ -142,7 +142,7 @@ export default class MagicLinkController<A extends Application> extends Controll
email: link.getOrFail('email'),
type: link.getOrFail('action_type'),
validUntil: link.getExpirationDate().getTime(),
websocketUrl: config.get<string>('public_websocket_url') + this.magicLinkWebsocketPath,
websocketUrl: config.get<string>('app.public_websocket_url') + this.magicLinkWebsocketPath,
});
}

View File

@ -89,7 +89,7 @@ export default class MailComponent extends ApplicationComponent {
// Set locals
locals.mail_subject = options.subject;
locals.mail_to = options.to;
locals.mail_link = config.get<string>('public_url') +
locals.mail_link = config.get<string>('app.public_url') +
route('mail', [template.template], locals);
Object.assign(locals, this.getApp().as(FrontendToolsComponent).getGlobals().get());

View File

@ -24,7 +24,7 @@ export default class WebSocketServerComponent extends ApplicationComponent {
const globals = app.asOptional(FrontendToolsComponent)?.getGlobals();
if (globals) {
globals.set('websocketUrl', config.get('public_websocket_url'));
globals.set('websocketUrl', config.get('app.public_websocket_url'));
}
}

View File

@ -17,7 +17,7 @@ import TestApp from "./TestApp.js";
const packageJson = JSON.parse((await fs.readFile('package.json')).toString());
const app = new TestApp(packageJson.version, config.get<string>('listen_addr'), config.get<number>('port'));
const app = new TestApp(packageJson.version, config.get<string>('app.listen_addr'), config.get<number>('app.port'));
await app.start();
})().catch(err => {
logger.error(err);