mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-19 17:55:17 -04:00
Add prettier for codestyle and re-format everything (#1294)
This commit is contained in:
parent
8b78154075
commit
0aae1f70d2
319 changed files with 4809 additions and 3936 deletions
|
@ -12,5 +12,5 @@ export const getConfig = async (): Promise<Config> => {
|
|||
...defaultFetchConfig
|
||||
})
|
||||
expectResponseCode(response)
|
||||
return await response.json() as Promise<Config>
|
||||
return (await response.json()) as Promise<Config>
|
||||
}
|
||||
|
|
60
src/api/config/types.d.ts
vendored
60
src/api/config/types.d.ts
vendored
|
@ -5,27 +5,27 @@
|
|||
*/
|
||||
|
||||
export interface Config {
|
||||
allowAnonymous: boolean,
|
||||
allowRegister: boolean,
|
||||
authProviders: AuthProvidersState,
|
||||
branding: BrandingConfig,
|
||||
customAuthNames: CustomAuthNames,
|
||||
useImageProxy: boolean,
|
||||
specialUrls: SpecialUrls,
|
||||
version: BackendVersion,
|
||||
plantumlServer: string | null,
|
||||
maxDocumentLength: number,
|
||||
allowAnonymous: boolean
|
||||
allowRegister: boolean
|
||||
authProviders: AuthProvidersState
|
||||
branding: BrandingConfig
|
||||
customAuthNames: CustomAuthNames
|
||||
useImageProxy: boolean
|
||||
specialUrls: SpecialUrls
|
||||
version: BackendVersion
|
||||
plantumlServer: string | null
|
||||
maxDocumentLength: number
|
||||
iframeCommunication: iframeCommunicationConfig
|
||||
}
|
||||
|
||||
export interface iframeCommunicationConfig {
|
||||
editorOrigin: string,
|
||||
editorOrigin: string
|
||||
rendererOrigin: string
|
||||
}
|
||||
|
||||
export interface BrandingConfig {
|
||||
name: string,
|
||||
logo: string,
|
||||
name: string
|
||||
logo: string
|
||||
}
|
||||
|
||||
export interface BackendVersion {
|
||||
|
@ -37,27 +37,27 @@ export interface BackendVersion {
|
|||
}
|
||||
|
||||
export interface AuthProvidersState {
|
||||
facebook: boolean,
|
||||
github: boolean,
|
||||
twitter: boolean,
|
||||
gitlab: boolean,
|
||||
dropbox: boolean,
|
||||
ldap: boolean,
|
||||
google: boolean,
|
||||
saml: boolean,
|
||||
oauth2: boolean,
|
||||
internal: boolean,
|
||||
openid: boolean,
|
||||
facebook: boolean
|
||||
github: boolean
|
||||
twitter: boolean
|
||||
gitlab: boolean
|
||||
dropbox: boolean
|
||||
ldap: boolean
|
||||
google: boolean
|
||||
saml: boolean
|
||||
oauth2: boolean
|
||||
internal: boolean
|
||||
openid: boolean
|
||||
}
|
||||
|
||||
export interface CustomAuthNames {
|
||||
ldap: string;
|
||||
oauth2: string;
|
||||
saml: string;
|
||||
ldap: string
|
||||
oauth2: string
|
||||
saml: string
|
||||
}
|
||||
|
||||
export interface SpecialUrls {
|
||||
privacy?: string,
|
||||
termsOfUse?: string,
|
||||
imprint?: string,
|
||||
privacy?: string
|
||||
termsOfUse?: string
|
||||
imprint?: string
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import { HistoryEntryDto, HistoryEntryPutDto, HistoryEntryUpdateDto } from './ty
|
|||
export const getHistory = async (): Promise<HistoryEntryDto[]> => {
|
||||
const response = await fetch(getApiUrl() + 'me/history')
|
||||
expectResponseCode(response)
|
||||
return await response.json() as Promise<HistoryEntryDto[]>
|
||||
return (await response.json()) as Promise<HistoryEntryDto[]>
|
||||
}
|
||||
|
||||
export const postHistory = async (entries: HistoryEntryPutDto[]): Promise<void> => {
|
||||
|
|
|
@ -9,7 +9,7 @@ import { defaultFetchConfig, expectResponseCode, getApiUrl } from '../utils'
|
|||
import { isMockMode } from '../../utils/test-modes'
|
||||
|
||||
export const getMe = async (): Promise<UserResponse> => {
|
||||
const response = await fetch(getApiUrl() + `me${ isMockMode() ? '-get' : '' }`, {
|
||||
const response = await fetch(getApiUrl() + `me${isMockMode() ? '-get' : ''}`, {
|
||||
...defaultFetchConfig
|
||||
})
|
||||
expectResponseCode(response)
|
||||
|
|
|
@ -16,7 +16,7 @@ export const getProxiedUrl = async (imageUrl: string): Promise<ImageProxyRespons
|
|||
})
|
||||
})
|
||||
expectResponseCode(response)
|
||||
return await response.json() as Promise<ImageProxyResponse>
|
||||
return (await response.json()) as Promise<ImageProxyResponse>
|
||||
}
|
||||
|
||||
export interface UploadedMedia {
|
||||
|
@ -34,5 +34,5 @@ export const uploadFile = async (noteId: string, contentType: string, media: Blo
|
|||
body: media
|
||||
})
|
||||
expectResponseCode(response, 201)
|
||||
return await response.json() as Promise<UploadedMedia>
|
||||
return (await response.json()) as Promise<UploadedMedia>
|
||||
}
|
||||
|
|
|
@ -11,15 +11,15 @@ import { isMockMode } from '../../utils/test-modes'
|
|||
export const getNote = async (noteId: string): Promise<NoteDto> => {
|
||||
// The "-get" suffix is necessary, because in our mock api (filesystem) the note id might already be a folder.
|
||||
// TODO: [mrdrogdrog] replace -get with actual api route as soon as api backend is ready.
|
||||
const response = await fetch(getApiUrl() + `notes/${ noteId }${ isMockMode() ? '-get' : '' }`, {
|
||||
const response = await fetch(getApiUrl() + `notes/${noteId}${isMockMode() ? '-get' : ''}`, {
|
||||
...defaultFetchConfig
|
||||
})
|
||||
expectResponseCode(response)
|
||||
return await response.json() as Promise<NoteDto>
|
||||
return (await response.json()) as Promise<NoteDto>
|
||||
}
|
||||
|
||||
export const deleteNote = async (noteId: string): Promise<void> => {
|
||||
const response = await fetch(getApiUrl() + `notes/${ noteId }`, {
|
||||
const response = await fetch(getApiUrl() + `notes/${noteId}`, {
|
||||
...defaultFetchConfig,
|
||||
method: 'DELETE'
|
||||
})
|
||||
|
|
|
@ -11,24 +11,24 @@ import { Revision, RevisionListEntry } from './types'
|
|||
const revisionCache = new Cache<string, Revision>(3600)
|
||||
|
||||
export const getRevision = async (noteId: string, timestamp: number): Promise<Revision> => {
|
||||
const cacheKey = `${ noteId }:${ timestamp }`
|
||||
const cacheKey = `${noteId}:${timestamp}`
|
||||
if (revisionCache.has(cacheKey)) {
|
||||
return revisionCache.get(cacheKey)
|
||||
}
|
||||
const response = await fetch(getApiUrl() + `notes/${ noteId }/revisions/${ timestamp }`, {
|
||||
const response = await fetch(getApiUrl() + `notes/${noteId}/revisions/${timestamp}`, {
|
||||
...defaultFetchConfig
|
||||
})
|
||||
expectResponseCode(response)
|
||||
const revisionData = await response.json() as Revision
|
||||
const revisionData = (await response.json()) as Revision
|
||||
revisionCache.put(cacheKey, revisionData)
|
||||
return revisionData
|
||||
}
|
||||
|
||||
export const getAllRevisions = async (noteId: string): Promise<RevisionListEntry[]> => {
|
||||
// TODO Change 'revisions-list' to 'revisions' as soon as the backend is ready to serve some data!
|
||||
const response = await fetch(getApiUrl() + `notes/${ noteId }/revisions-list`, {
|
||||
const response = await fetch(getApiUrl() + `notes/${noteId}/revisions-list`, {
|
||||
...defaultFetchConfig
|
||||
})
|
||||
expectResponseCode(response)
|
||||
return await response.json() as Promise<RevisionListEntry[]>
|
||||
return (await response.json()) as Promise<RevisionListEntry[]>
|
||||
}
|
||||
|
|
|
@ -8,25 +8,25 @@ import { defaultFetchConfig, expectResponseCode, getApiUrl } from '../utils'
|
|||
import { AccessToken, AccessTokenSecret } from './types'
|
||||
|
||||
export const getAccessTokenList = async (): Promise<AccessToken[]> => {
|
||||
const response = await fetch(`${ getApiUrl() }tokens`, {
|
||||
const response = await fetch(`${getApiUrl()}tokens`, {
|
||||
...defaultFetchConfig
|
||||
})
|
||||
expectResponseCode(response)
|
||||
return await response.json() as AccessToken[]
|
||||
return (await response.json()) as AccessToken[]
|
||||
}
|
||||
|
||||
export const postNewAccessToken = async (label: string): Promise<AccessToken & AccessTokenSecret> => {
|
||||
const response = await fetch(`${ getApiUrl() }tokens`, {
|
||||
const response = await fetch(`${getApiUrl()}tokens`, {
|
||||
...defaultFetchConfig,
|
||||
method: 'POST',
|
||||
body: label
|
||||
})
|
||||
expectResponseCode(response)
|
||||
return await response.json() as (AccessToken & AccessTokenSecret)
|
||||
return (await response.json()) as AccessToken & AccessTokenSecret
|
||||
}
|
||||
|
||||
export const deleteAccessToken = async (timestamp: number): Promise<void> => {
|
||||
const response = await fetch(`${ getApiUrl() }tokens/${ timestamp }`, {
|
||||
const response = await fetch(`${getApiUrl()}tokens/${timestamp}`, {
|
||||
...defaultFetchConfig,
|
||||
method: 'DELETE'
|
||||
})
|
||||
|
|
|
@ -14,7 +14,7 @@ export const getUserById = async (userid: string): Promise<UserResponse> => {
|
|||
if (cache.has(userid)) {
|
||||
return cache.get(userid)
|
||||
}
|
||||
const response = await fetch(`${ getApiUrl() }/users/${ userid }`, {
|
||||
const response = await fetch(`${getApiUrl()}/users/${userid}`, {
|
||||
...defaultFetchConfig
|
||||
})
|
||||
expectResponseCode(response)
|
||||
|
|
|
@ -24,6 +24,6 @@ export const getApiUrl = (): string => {
|
|||
|
||||
export const expectResponseCode = (response: Response, code = 200): void => {
|
||||
if (response.status !== code) {
|
||||
throw new Error(`response code is not ${ code }`)
|
||||
throw new Error(`response code is not ${code}`)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue