bjarneo 0c86efd56c
refactor: use fastify vite for the dev server (#284)
* 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
2024-03-11 13:43:20 +01:00

55 lines
1.2 KiB
JavaScript

import config from '../config';
export const getUsers = async (skip = 0) => {
const data = await fetch(`${config.get('api.host')}/admin/users?skip=${skip}`, {
method: 'GET',
cache: 'no-cache',
headers: {
'Content-Type': 'application/json',
},
});
if (data.status === 401) {
return {
statusCode: 401,
};
}
return data.json();
};
const userFetchTemplate = async (data, method = 'GET') => {
const response = await fetch(`${config.get('api.host')}/admin/users`, {
method,
cache: 'no-cache',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
});
const json = await response.json();
if ([401, 403, 409, 500].includes(response.status)) {
return {
statusCode: response.status,
error: json.error,
type: json?.type,
};
}
return json;
};
export const updateUser = async (data) => {
return userFetchTemplate(data, 'PUT');
};
export const addUser = async (data) => {
return userFetchTemplate(data, 'POST');
};
export const deleteUser = async (data) => {
return userFetchTemplate(data, 'DELETE');
};