mirror of
https://github.com/dsec-hub/dsec-notebook.git
synced 2026-09-22 07:24:27 +00:00
fix server error
This commit is contained in:
parent
d4527d74fd
commit
f826141940
3 changed files with 18 additions and 5 deletions
|
|
@ -14,6 +14,9 @@ RUN npm ci
|
|||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
# Keep only production dependencies so they can be copied into the runtime image.
|
||||
RUN npm prune --omit=dev
|
||||
|
||||
# ---- Runtime stage ----
|
||||
FROM node:24-alpine AS runtime
|
||||
|
||||
|
|
@ -25,6 +28,8 @@ ENV NODE_ENV=production \
|
|||
DATABASE_PATH=data/dsec.db
|
||||
|
||||
COPY --from=build /app/build ./build
|
||||
COPY --from=build /app/package.json ./package.json
|
||||
COPY --from=build /app/node_modules ./node_modules
|
||||
|
||||
RUN mkdir -p data && chown -R node:node /app
|
||||
USER node
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ async function call(name: string, args: Record<string, any> = {}): Promise<any>
|
|||
body: JSON.stringify({ fn: name, args }),
|
||||
});
|
||||
|
||||
const data = await res.json();
|
||||
if (!data.ok) {
|
||||
throw new Error(data.error ?? "Request failed");
|
||||
const data = await res.json().catch(() => null);
|
||||
if (!res.ok || !data?.ok) {
|
||||
throw new Error(data?.error ?? `Request failed (${res.status})`);
|
||||
}
|
||||
return data.result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,10 +5,16 @@
|
|||
|
||||
let units: UnitDoc[] = $state([]);
|
||||
let loading = $state(true);
|
||||
let error = $state("");
|
||||
|
||||
onMount(async () => {
|
||||
try {
|
||||
units = (await query("units:getAll")) as UnitDoc[];
|
||||
} catch (err: any) {
|
||||
error = err.message ?? "Failed to load units";
|
||||
} finally {
|
||||
loading = false;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
|
@ -38,6 +44,8 @@
|
|||
<p class="kicker mb-6">Units</p>
|
||||
{#if loading}
|
||||
<p class="kicker">Loading</p>
|
||||
{:else if error}
|
||||
<p class="kicker">{error}</p>
|
||||
{:else}
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2">
|
||||
{#each units as unit}
|
||||
|
|
|
|||
Loading…
Reference in a new issue