qa: Refactor gitlab use
This commit is contained in:
parent
c31f76e9c3
commit
d4cad767eb
7 changed files with 145 additions and 54 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Reference in a new issue