qa: Refactor gitlab use

This commit is contained in:
nemunaire 2023-11-26 12:57:04 +01:00
commit d4cad767eb
7 changed files with 145 additions and 54 deletions

View file

@ -27,3 +27,30 @@ export const auth = derived(
version,
$version => $version.auth,
);
function createGitlabStore() {
const { subscribe, set, update } = writable(null);
return {
subscribe,
set,
update,
refresh: async () => {
const res = await fetch('api/gitlab/token', {headers: {'Accept': 'application/json'}});
if (res.status === 200) {
const token = await res.json();
update((m) => token);
return token;
} else {
update((m) => null);
return null;
}
},
};
}
export const gitlab = createGitlabStore();