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:
Philip Molares 2020-05-27 15:43:28 +02:00 committed by GitHub
parent efb6513205
commit eba59ae622
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
70 changed files with 2413 additions and 1867 deletions

View file

@ -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>
}

View file

@ -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)
}