mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-19 17:55:17 -04:00
Restructure redux code (#109)
* Restructure redux code Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> Co-authored-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
parent
db5bec7000
commit
570c45017c
28 changed files with 214 additions and 231 deletions
8
src/api/backend-config/index.ts
Normal file
8
src/api/backend-config/index.ts
Normal file
|
@ -0,0 +1,8 @@
|
|||
import { expectResponseCode, getBackendUrl } from '../../utils/apiUtils'
|
||||
import { BackendConfig } from './types'
|
||||
|
||||
export const getBackendConfig = async (): Promise<BackendConfig> => {
|
||||
const response = await fetch(getBackendUrl() + '/config')
|
||||
expectResponseCode(response)
|
||||
return await response.json() as Promise<BackendConfig>
|
||||
}
|
39
src/api/backend-config/types.ts
Normal file
39
src/api/backend-config/types.ts
Normal file
|
@ -0,0 +1,39 @@
|
|||
export interface BackendConfig {
|
||||
allowAnonymous: boolean,
|
||||
authProviders: AuthProvidersState,
|
||||
customAuthNames: CustomAuthNames,
|
||||
specialLinks: SpecialLinks,
|
||||
version: BackendVersion,
|
||||
}
|
||||
|
||||
export interface BackendVersion {
|
||||
version: string,
|
||||
sourceCodeUrl: string
|
||||
issueTrackerUrl: string
|
||||
}
|
||||
|
||||
export interface AuthProvidersState {
|
||||
facebook: boolean,
|
||||
github: boolean,
|
||||
twitter: boolean,
|
||||
gitlab: boolean,
|
||||
dropbox: boolean,
|
||||
ldap: boolean,
|
||||
google: boolean,
|
||||
saml: boolean,
|
||||
oauth2: boolean,
|
||||
email: boolean,
|
||||
openid: boolean,
|
||||
}
|
||||
|
||||
export interface CustomAuthNames {
|
||||
ldap: string;
|
||||
oauth2: string;
|
||||
saml: string;
|
||||
}
|
||||
|
||||
export interface SpecialLinks {
|
||||
privacy: string,
|
||||
termsOfUse: string,
|
||||
imprint: string,
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
import { FrontendConfigState } from '../redux/frontend-config/types'
|
||||
import { BackendConfigState } from '../redux/backend-config/types'
|
||||
import { expectResponseCode, getBackendUrl } from '../utils/apiUtils'
|
||||
|
||||
export const getBackendConfig = async (): Promise<BackendConfigState> => {
|
||||
const response = await fetch(getBackendUrl() + '/config')
|
||||
expectResponseCode(response)
|
||||
return await response.json() as Promise<BackendConfigState>
|
||||
}
|
||||
|
||||
export const getFrontendConfig = async (baseUrl: string): Promise<FrontendConfigState> => {
|
||||
const response = await fetch(`${baseUrl}config.json`)
|
||||
expectResponseCode(response)
|
||||
return await response.json() as Promise<FrontendConfigState>
|
||||
}
|
8
src/api/frontend-config/index.ts
Normal file
8
src/api/frontend-config/index.ts
Normal file
|
@ -0,0 +1,8 @@
|
|||
import { expectResponseCode } from '../../utils/apiUtils'
|
||||
import { FrontendConfig } from './types'
|
||||
|
||||
export const getFrontendConfig = async (baseUrl: string): Promise<FrontendConfig> => {
|
||||
const response = await fetch(`${baseUrl}config.json`)
|
||||
expectResponseCode(response)
|
||||
return await response.json() as Promise<FrontendConfig>
|
||||
}
|
3
src/api/frontend-config/types.ts
Normal file
3
src/api/frontend-config/types.ts
Normal file
|
@ -0,0 +1,3 @@
|
|||
export interface FrontendConfig {
|
||||
backendUrl: string
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue