mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-20 10:15:17 -04:00
better linting (#72)
Improve linting and fix linting errors Signed-off-by: Philip Molares <philip.molares@udo.edu> Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
This commit is contained in:
parent
efb6513205
commit
eba59ae622
70 changed files with 2413 additions and 1867 deletions
|
@ -1,15 +1,15 @@
|
|||
import {FrontendConfigState} from "../redux/frontend-config/types";
|
||||
import {BackendConfigState} from "../redux/backend-config/types";
|
||||
import {expectResponseCode, getBackendUrl} from "../utils/apiUtils";
|
||||
import { FrontendConfigState } from '../redux/frontend-config/types'
|
||||
import { BackendConfigState } from '../redux/backend-config/types'
|
||||
import { expectResponseCode, getBackendUrl } from '../utils/apiUtils'
|
||||
|
||||
export const getBackendConfig = async () => {
|
||||
const response = await fetch(getBackendUrl() + '/backend-config.json');
|
||||
expectResponseCode(response);
|
||||
return await response.json() as Promise<BackendConfigState>;
|
||||
export const getBackendConfig: () => Promise<BackendConfigState> = async () => {
|
||||
const response = await fetch(getBackendUrl() + '/backend-config.json')
|
||||
expectResponseCode(response)
|
||||
return await response.json() as Promise<BackendConfigState>
|
||||
}
|
||||
|
||||
export const getFrontendConfig = async () => {
|
||||
const response = await fetch('config.json');
|
||||
expectResponseCode(response)
|
||||
return await response.json() as Promise<FrontendConfigState>;
|
||||
}
|
||||
export const getFrontendConfig: () => Promise<FrontendConfigState> = async () => {
|
||||
const response = await fetch('config.json')
|
||||
expectResponseCode(response)
|
||||
return await response.json() as Promise<FrontendConfigState>
|
||||
}
|
||||
|
|
115
src/api/user.ts
115
src/api/user.ts
|
@ -1,67 +1,72 @@
|
|||
import {expectResponseCode, getBackendUrl} from "../utils/apiUtils";
|
||||
import { expectResponseCode, getBackendUrl } from '../utils/apiUtils'
|
||||
|
||||
export const getMe = async () => {
|
||||
return fetch('/me');
|
||||
export const getMe: (() => Promise<meResponse>) = async () => {
|
||||
const response = await fetch('/me')
|
||||
expectResponseCode(response)
|
||||
return (await response.json()) as meResponse
|
||||
}
|
||||
|
||||
export const postEmailLogin = async (email: string, password: string) => {
|
||||
const response = await fetch(getBackendUrl() + "/auth/email", {
|
||||
method: 'POST',
|
||||
mode: 'cors',
|
||||
cache: 'no-cache',
|
||||
credentials: 'same-origin',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
redirect: 'follow',
|
||||
referrerPolicy: 'no-referrer',
|
||||
body: JSON.stringify({
|
||||
email: email,
|
||||
password: password,
|
||||
})
|
||||
});
|
||||
|
||||
expectResponseCode(response);
|
||||
return await response.json();
|
||||
export interface meResponse {
|
||||
id: string
|
||||
name: string
|
||||
photo: string
|
||||
}
|
||||
|
||||
export const postLdapLogin = async (username: string, password: string) => {
|
||||
const response = await fetch(getBackendUrl() + "/auth/ldap", {
|
||||
method: 'POST',
|
||||
mode: 'cors',
|
||||
cache: 'no-cache',
|
||||
credentials: 'same-origin',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
redirect: 'follow',
|
||||
referrerPolicy: 'no-referrer',
|
||||
body: JSON.stringify({
|
||||
username: username,
|
||||
password: password,
|
||||
})
|
||||
export const postEmailLogin: ((email: string, password: string) => Promise<void>) = async (email, password) => {
|
||||
const response = await fetch(getBackendUrl() + '/auth/email', {
|
||||
method: 'POST',
|
||||
mode: 'cors',
|
||||
cache: 'no-cache',
|
||||
credentials: 'same-origin',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
redirect: 'follow',
|
||||
referrerPolicy: 'no-referrer',
|
||||
body: JSON.stringify({
|
||||
email: email,
|
||||
password: password
|
||||
})
|
||||
})
|
||||
|
||||
expectResponseCode(response)
|
||||
return await response.json();
|
||||
expectResponseCode(response)
|
||||
}
|
||||
|
||||
export const postOpenIdLogin = async (openId: string) => {
|
||||
const response = await fetch(getBackendUrl() + "/auth/openid", {
|
||||
method: 'POST',
|
||||
mode: 'cors',
|
||||
cache: 'no-cache',
|
||||
credentials: 'same-origin',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
redirect: 'follow',
|
||||
referrerPolicy: 'no-referrer',
|
||||
body: JSON.stringify({
|
||||
openId: openId
|
||||
})
|
||||
export const postLdapLogin: ((email: string, password: string) => Promise<void>) = async (username, password) => {
|
||||
const response = await fetch(getBackendUrl() + '/auth/ldap', {
|
||||
method: 'POST',
|
||||
mode: 'cors',
|
||||
cache: 'no-cache',
|
||||
credentials: 'same-origin',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
redirect: 'follow',
|
||||
referrerPolicy: 'no-referrer',
|
||||
body: JSON.stringify({
|
||||
username: username,
|
||||
password: password
|
||||
})
|
||||
})
|
||||
|
||||
expectResponseCode(response)
|
||||
return await response.json();
|
||||
expectResponseCode(response)
|
||||
}
|
||||
|
||||
export const postOpenIdLogin: ((openid: string) => Promise<void>) = async (openId: string) => {
|
||||
const response = await fetch(getBackendUrl() + '/auth/openid', {
|
||||
method: 'POST',
|
||||
mode: 'cors',
|
||||
cache: 'no-cache',
|
||||
credentials: 'same-origin',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
redirect: 'follow',
|
||||
referrerPolicy: 'no-referrer',
|
||||
body: JSON.stringify({
|
||||
openId: openId
|
||||
})
|
||||
})
|
||||
|
||||
expectResponseCode(response)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue