Docker compose almost working
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { n as noop, f as safe_not_equal } from "./ssr.js";
|
||||
import { n as noop, d as safe_not_equal } from "./ssr.js";
|
||||
const subscriber_queue = [];
|
||||
function readable(value, start) {
|
||||
return {
|
||||
|
||||
@@ -204,7 +204,7 @@ const options = {
|
||||
<div class="error">
|
||||
<span class="status">` + status + '</span>\n <div class="message">\n <h1>' + message + "</h1>\n </div>\n </div>\n </body>\n</html>\n"
|
||||
},
|
||||
version_hash: "vmq992"
|
||||
version_hash: "1xthrp6"
|
||||
};
|
||||
async function get_hooks() {
|
||||
return {};
|
||||
|
||||
@@ -7,29 +7,43 @@ class Score {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
let localStorageKey = "scores";
|
||||
function isBrowser() {
|
||||
return typeof window !== "undefined" && typeof window.localStorage !== "undefined";
|
||||
const api_url = "http://naaturel.be:5000/api";
|
||||
async function getLeaderboard() {
|
||||
return await handleRequest(
|
||||
`${api_url}/api/leaderboard/`,
|
||||
{ method: "GET" }
|
||||
);
|
||||
}
|
||||
function createStore() {
|
||||
const storedValue = isBrowser() ? localStorage.getItem(localStorageKey) : null;
|
||||
const { set, update, subscribe } = writable(!storedValue ? [] : JSON.parse(storedValue));
|
||||
if (isBrowser()) subscribe((value) => localStorage.setItem(localStorageKey, JSON.stringify(value)));
|
||||
async function handleRequest(url, init) {
|
||||
return await fetch(url, init).then((response) => {
|
||||
if (response.status === 500) throw new Error(`${response.text()}`);
|
||||
if (!response.ok) throw new Error(`${response.status} : ${response.body}`);
|
||||
return response;
|
||||
}).then((response) => {
|
||||
return response.json();
|
||||
}).catch((error) => {
|
||||
return `Exception: ${error.message}`;
|
||||
});
|
||||
}
|
||||
function createStore(scores) {
|
||||
const { set, update, subscribe } = writable(scores);
|
||||
return {
|
||||
update,
|
||||
subscribe,
|
||||
set: (value) => set(!value ? [] : value),
|
||||
reset: () => set([]),
|
||||
add: (playerName, value) => {
|
||||
update((scores) => {
|
||||
let s = [...scores, new Score({ playerName, value })];
|
||||
update((scores2) => {
|
||||
let s = [...scores2, new Score({ playerName, value })];
|
||||
if (s.length >= 2) s.sort((s1, s2) => s1.value - s2.value);
|
||||
return s;
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
const scoreStore = createStore();
|
||||
export {
|
||||
scoreStore as s
|
||||
};
|
||||
async function createStoreFromAPI() {
|
||||
console.log("http://naaturel.be:5000/api");
|
||||
let scores = await getLeaderboard();
|
||||
return createStore(scores);
|
||||
}
|
||||
createStoreFromAPI();
|
||||
|
||||
@@ -37,9 +37,6 @@ function setContext(key, context) {
|
||||
function getContext(key) {
|
||||
return get_current_component().$$.context.get(key);
|
||||
}
|
||||
function ensure_array_like(array_like_or_iterator) {
|
||||
return array_like_or_iterator?.length !== void 0 ? array_like_or_iterator : Array.from(array_like_or_iterator);
|
||||
}
|
||||
const ATTR_REGEX = /[&"<]/g;
|
||||
const CONTENT_REGEX = /[&<]/g;
|
||||
function escape(value, is_attr = false) {
|
||||
@@ -56,14 +53,6 @@ function escape(value, is_attr = false) {
|
||||
}
|
||||
return escaped + str.substring(last);
|
||||
}
|
||||
function each(items, fn) {
|
||||
items = ensure_array_like(items);
|
||||
let str = "";
|
||||
for (let i = 0; i < items.length; i += 1) {
|
||||
str += fn(items[i], i);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
const missing_component = {
|
||||
$$render: () => ""
|
||||
};
|
||||
@@ -122,9 +111,8 @@ export {
|
||||
add_attribute as a,
|
||||
subscribe as b,
|
||||
create_ssr_component as c,
|
||||
each as d,
|
||||
safe_not_equal as d,
|
||||
escape as e,
|
||||
safe_not_equal as f,
|
||||
getContext as g,
|
||||
missing_component as m,
|
||||
noop as n,
|
||||
|
||||
Reference in New Issue
Block a user