Files
homebrewery-oidc/server/fork/assets/errors.js
T
dev-bot Bot aeca3926a3
Image / Image bauen und pushen (push) Successful in 4m29s
CI / App (npm ci + Build, ESLint, Stylelint, Jest) (push) Successful in 2m40s
CI / Storage (mongo) (push) Successful in 1m35s
CI / Storage (postgres) (push) Successful in 1m30s
feat(assets): Bild-Upload ins verbundene Git-Repo (#10) (#26)
Upload-Endpunkt POST /api/git/brews/:editId/assets (Magic Bytes, konfigurierbare Limits HB_ASSET_*, Dedupe, Commit ins Repo, Snapshot in brew_assets) und Auslieferung /git-assets/:shareId/:sha256.:ext gemäß ADR 0004. Postgres-Migration 0003, Mongo-Repo, Editor-Button, Drag-and-drop und Einfügen.

Closes #10

Co-authored-by: Dev (Paperclip) <dev-bot@noreply.git.morlana.online>
2026-11-26 01:39:34 +00:00

26 lines
1.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { GitError } from '../git/errors.js';
// Fehlercodes der Bild-Ablage (ADR 0004). Git-Fehler (G02–G05, G08) kommen unverändert aus dem Git-Backend.
export const ASSET_ERRORS = {
A01 : { status: 413, message: 'Das Bild ist zu groß.' },
A02 : { status: 415, message: 'Dieser Dateityp ist nicht erlaubt.' },
A03 : { status: 413, message: 'Das Speicherlimit für Bilder dieses Brews ist erreicht.' },
A04 : { status: 423, message: 'Der Brew ist gesperrt, es können keine Bilder hochgeladen werden.' },
A05 : { status: 400, message: 'Bilder können nur zu Brews hochgeladen werden, die mit einem Git-Repository verbunden sind.' },
A06 : { status: 400, message: 'Es wurde keine Bilddatei übertragen.' },
A07 : { status: 503, message: 'Der Bild-Upload ist auf diesem Server nicht aktiviert.' }
};
export class AssetError extends GitError {
constructor(code, message, extra = {}) {
super(code, message ?? ASSET_ERRORS[code]?.message, { ...extra, status: extra.status ?? ASSET_ERRORS[code]?.status });
this.name = 'AssetError';
}
}
export const formatBytes = (n)=>{
if(n >= 1024 * 1024) return `${+(n / 1024 / 1024).toFixed(1)} MiB`;
if(n >= 1024) return `${Math.round(n / 1024)} KiB`;
return `${n} Byte`;
};