mirror of
https://github.com/mudita/mudita-center.git
synced 2025-12-23 22:28:03 -05:00
Co-authored-by: MateuszMudita <165778944+MateuszMudita@users.noreply.github.com> Co-authored-by: Łukasz Kowalczyk <37898730+lkowalczyk87@users.noreply.github.com> Co-authored-by: slawomir-werner <slawomir.werner@mudita.com> Co-authored-by: Michał Kurczewski <michalkurczewski94@gmail.com>
45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
/**
|
|
* Copyright (c) Mudita sp. z o.o. All rights reserved.
|
|
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
|
|
*/
|
|
|
|
import axios from "axios"
|
|
import { Configuration } from "../libs/core/settings/dto"
|
|
import { MuditaCenterServerRoutes } from "../libs/shared/utils/src/lib/mudita-center-server-routes"
|
|
|
|
const path = require("path")
|
|
const fs = require("fs-extra")
|
|
|
|
require("dotenv").config({
|
|
path: path.join(__dirname, "../.env"),
|
|
})
|
|
|
|
let defaultData = require("../libs/core/settings/static/default-app-configuration.json")
|
|
|
|
;(async () => {
|
|
const jsonPath = path.join(
|
|
__dirname,
|
|
"..",
|
|
"libs",
|
|
"core",
|
|
"settings",
|
|
"static",
|
|
"app-configuration.json"
|
|
)
|
|
|
|
try {
|
|
await fs.ensureDir(path.resolve(jsonPath))
|
|
|
|
const url = `${process.env.MUDITA_CENTER_SERVER_URL}/${MuditaCenterServerRoutes.AppConfigurationV2}?version=v2-app-configuration`
|
|
const { status, data } = await axios.get<Configuration>(url)
|
|
|
|
if (status === 200 && data !== undefined) {
|
|
await fs.writeJson(path.resolve(jsonPath), data)
|
|
} else {
|
|
await fs.writeJson(path.resolve(jsonPath), defaultData)
|
|
}
|
|
} catch (error: any) {
|
|
await fs.writeJson(path.resolve(jsonPath), defaultData)
|
|
}
|
|
})()
|