* refactor: use fastify vite for the server by doing this we do not need to have local hacks for the routes. No local proxy needed. Everything just works. * fix: update the dockerfile build path * fix: update package.json * fix: fonts path
97 lines
2.1 KiB
JavaScript
97 lines
2.1 KiB
JavaScript
import config from '../config';
|
|
|
|
export const signIn = async (username, password) => {
|
|
const data = await fetch(`${config.get('api.host')}/authentication/signin`, {
|
|
method: 'POST',
|
|
cache: 'no-cache',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
body: JSON.stringify({ username, password }),
|
|
});
|
|
|
|
if (data.status === 401) {
|
|
return {
|
|
statusCode: 401,
|
|
};
|
|
}
|
|
|
|
const json = await data.json();
|
|
|
|
if (data.status === 403) {
|
|
return {
|
|
statusCode: 403,
|
|
message: json.message,
|
|
};
|
|
}
|
|
|
|
return json;
|
|
};
|
|
|
|
export const signUp = async (email, username, password) => {
|
|
const data = await fetch(`${config.get('api.host')}/authentication/signup`, {
|
|
method: 'POST',
|
|
cache: 'no-cache',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
body: JSON.stringify({ email, username, password }),
|
|
});
|
|
|
|
const json = await data.json();
|
|
|
|
if (data.status === 403) {
|
|
return {
|
|
statusCode: 403,
|
|
message: json.message,
|
|
};
|
|
}
|
|
|
|
return json;
|
|
};
|
|
|
|
export const signOut = async () => {
|
|
const data = await fetch(`${config.get('api.host')}/authentication/signout`, {
|
|
method: 'POST',
|
|
cache: 'no-cache',
|
|
});
|
|
|
|
return data.json();
|
|
};
|
|
|
|
export const verify = async () => {
|
|
const data = await fetch(`${config.get('api.host')}/authentication/verify`, {
|
|
method: 'GET',
|
|
cache: 'no-cache',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
});
|
|
|
|
if (data.status === 401) {
|
|
return {
|
|
statusCode: 401,
|
|
};
|
|
}
|
|
|
|
return data.json();
|
|
};
|
|
|
|
export const refresh = async () => {
|
|
const data = await fetch(`${config.get('api.host')}/authentication/refresh`, {
|
|
method: 'GET',
|
|
cache: 'no-cache',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
});
|
|
|
|
if (data.status === 401) {
|
|
return {
|
|
statusCode: 401,
|
|
};
|
|
}
|
|
|
|
return data.json();
|
|
};
|