mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-09 13:51:57 -04:00

Co-authored-by: Philip Molares <philip.molares@udo.edu> Signed-off-by: Philip Molares <philip.molares@udo.edu> Signed-off-by: Erik Michelson <github@erik.michelson.eu>
22 lines
768 B
TypeScript
22 lines
768 B
TypeScript
/*
|
|
* SPDX-FileCopyrightText: 2025 The HedgeDoc developers (see AUTHORS file)
|
|
*
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
import { GetApiRequestBuilder } from '../common/api-request-builder/get-api-request-builder'
|
|
import { isBuildTime } from '../../utils/test-modes'
|
|
import type { FrontendConfigDto } from '@hedgedoc/commons'
|
|
|
|
/**
|
|
* Fetches the frontend config from the backend.
|
|
*
|
|
* @return The frontend config.
|
|
* @throws {Error} when the api request wasn't successful.
|
|
*/
|
|
export const getConfig = async (baseUrl?: string): Promise<FrontendConfigDto | undefined> => {
|
|
if (isBuildTime) {
|
|
return undefined
|
|
}
|
|
const response = await new GetApiRequestBuilder<FrontendConfigDto>('config', baseUrl).sendRequest()
|
|
return response.asParsedJsonObject()
|
|
}
|