mirror of
https://github.com/laurent22/joplin.git
synced 2025-01-02 12:47:41 +02:00
29 lines
622 B
TypeScript
29 lines
622 B
TypeScript
import { rtrimSlashes } from '@joplin/lib/path-utils';
|
|
import { Config } from './utils/types';
|
|
|
|
let baseConfig_: Config = null;
|
|
let baseUrl_: string = null;
|
|
|
|
export function initConfig(baseConfig: Config) {
|
|
baseConfig_ = baseConfig;
|
|
}
|
|
|
|
function config(): Config {
|
|
if (!baseConfig_) throw new Error('Config has not been initialized!');
|
|
return baseConfig_;
|
|
}
|
|
|
|
export function baseUrl() {
|
|
if (baseUrl_) return baseUrl_;
|
|
|
|
if (process.env.JOPLIN_BASE_URL) {
|
|
baseUrl_ = rtrimSlashes(process.env.JOPLIN_BASE_URL);
|
|
} else {
|
|
baseUrl_ = `http://localhost:${config().port}`;
|
|
}
|
|
|
|
return baseUrl_;
|
|
}
|
|
|
|
export default config;
|