Serve compiled front from the same application

also add embedded build for production
This commit is contained in:
2026-02-11 01:12:53 +01:00
parent 8fc5ff84c2
commit e127088195
28 changed files with 200 additions and 130 deletions

View File

@@ -1,13 +1,11 @@
import { useAuthStore } from './auth.store.js'
const baseUrl = "http://localhost:8080"
export function getInventaireImagePathOrDefault(path) {
return getImagePathOrGivenDefault(path, "../../defaultinventairebook.png")
return getImagePathOrGivenDefault(path, "../../image/defaultinventairebook.png")
}
export function getImagePathOrDefault(path) {
return getImagePathOrGivenDefault(path, "../defaultbook.png")
return getImagePathOrGivenDefault(path, "../image/defaultbook.png")
}
export function getImagePathOrGivenDefault(path, defaultpath) {
@@ -16,7 +14,7 @@ export function getImagePathOrGivenDefault(path, defaultpath) {
} else if (path.startsWith("https://")) {
return path;
} else {
return baseUrl + path;
return path;
}
}
@@ -38,78 +36,78 @@ function useFetch(data, error, url) {
export function getMyBooks(data, error, arg, limit, offset) {
const queryParams = new URLSearchParams({limit: limit, offset: offset});
return useFetch(data, error, baseUrl + '/mybooks/' + arg + "?" + queryParams.toString());
return useFetch(data, error, '/ws/mybooks/' + arg + "?" + queryParams.toString());
}
export function getSearchBooks(data, error, searchterm, lang, searchInventaire, limit, offset) {
const queryParams = new URLSearchParams({lang: lang, inventaire: searchInventaire, limit: limit, offset: offset});
return useFetch(data, error, baseUrl + '/search/' + encodeURIComponent(searchterm) + "?" + queryParams.toString());
return useFetch(data, error, '/ws/search/' + encodeURIComponent(searchterm) + "?" + queryParams.toString());
}
export function getInventaireEditionBooks(data, error, inventaireId, lang, limit, offset) {
const queryParams = new URLSearchParams({lang: lang, limit: limit, offset: offset});
return useFetch(data, error, baseUrl + '/inventaire/books/' + encodeURIComponent(inventaireId) + "?" + queryParams.toString());
return useFetch(data, error, '/ws/inventaire/books/' + encodeURIComponent(inventaireId) + "?" + queryParams.toString());
}
export function getAuthor(data, error, id) {
return useFetch(data, error, baseUrl + '/author/' + id);
return useFetch(data, error, '/ws/author/' + id);
}
export function getAuthorBooks(data, error, id, limit, offset) {
const queryParams = new URLSearchParams({limit: limit, offset: offset});
return useFetch(data, error, baseUrl + '/author/' + id + "/books" + "?" + queryParams.toString());
return useFetch(data, error, '/ws/author/' + id + "/books" + "?" + queryParams.toString());
}
export function getBook(data, error, id) {
return useFetch(data, error, baseUrl + '/book/' + id);
return useFetch(data, error, '/ws/book/' + id);
}
export function postBook(book) {
return genericPayloadCall('/book', book.value, 'POST')
return genericPayloadCall('/ws/book', book.value, 'POST')
}
export async function postImportBook(id, language) {
return genericPayloadCall('/importbook', {inventaireid: id, lang: language}, 'POST');
return genericPayloadCall('/ws/importbook', {inventaireid: id, lang: language}, 'POST');
}
export async function putReadBook(bookId) {
return genericPayloadCall('/book/' + bookId + "/read", {read: true}, 'PUT')
return genericPayloadCall('/ws/book/' + bookId + "/read", {read: true}, 'PUT')
}
export async function putUnreadBook(bookId) {
return genericPayloadCall('/book/' + bookId + "/read", {read: false}, 'PUT')
return genericPayloadCall('/ws/book/' + bookId + "/read", {read: false}, 'PUT')
}
export async function putEndReadDate(bookId, enddate) {
return genericPayloadCall('/book/' + bookId + "/read", {read: true, endDate: enddate}, 'PUT')
return genericPayloadCall('/ws/book/' + bookId + "/read", {read: true, endDate: enddate}, 'PUT')
}
export async function putEndReadDateUnset(bookId) {
return genericPayloadCall('/book/' + bookId + "/read", {read: true, endDate: "null"}, 'PUT')
return genericPayloadCall('/ws/book/' + bookId + "/read", {read: true, endDate: "null"}, 'PUT')
}
export async function putStartReadDateUnset(bookId) {
return genericPayloadCall('/book/' + bookId + "/startread", {startDate: "null"}, 'PUT')
return genericPayloadCall('/ws/book/' + bookId + "/startread", {startDate: "null"}, 'PUT')
}
export async function putStartReadDate(bookId, startdate) {
return genericPayloadCall('/book/' + bookId + "/startread", {startDate: startdate}, 'PUT')
return genericPayloadCall('/ws/book/' + bookId + "/startread", {startDate: startdate}, 'PUT')
}
export async function putWantReadBook(bookId, payload) {
return genericPayloadCall('/book/' + bookId + "/wantread", payload, 'PUT')
return genericPayloadCall('/ws/book/' + bookId + "/wantread", payload, 'PUT')
}
export async function putRateBook(bookId, payload) {
return genericPayloadCall('/book/' + bookId + "/rate", payload, 'PUT')
return genericPayloadCall('/ws/book/' + bookId + "/rate", payload, 'PUT')
}
export function postLogin(user) {
return genericPostCallNoAuth('/auth/login', user.value)
return genericPostCallNoAuth('/ws/auth/login', user.value)
}
export function postSignUp(user) {
return genericPostCallNoAuth('/auth/signup', user.value)
return genericPostCallNoAuth('/ws/auth/signup', user.value)
}
export function postImage(file) {
@@ -117,7 +115,7 @@ export function postImage(file) {
const formData = new FormData();
formData.append('file', file);
if (user != null) {
return fetch(baseUrl + "/upload/cover", {
return fetch("/ws/upload/cover", {
method: 'POST',
headers: {
'Authorization': 'Bearer ' + user.token
@@ -130,7 +128,7 @@ export function postImage(file) {
}
export function genericPostCallNoAuth(apiRoute, object) {
return fetch(baseUrl + apiRoute, {
return fetch(apiRoute, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
@@ -143,7 +141,7 @@ export function genericPayloadCall(apiRoute, object, method) {
const { user } = useAuthStore();
if (user != null) {
return fetch(baseUrl + apiRoute, {
return fetch(apiRoute, {
method: method,
headers: {
'Content-Type': 'application/json',