Harden bot, storage and web API

This commit is contained in:
Shinuwa 2026-06-30 17:25:00 +02:00
parent e974bc6660
commit 20624a5c9c
43 changed files with 1265 additions and 1012 deletions

21
test/serializers.test.js Normal file
View file

@ -0,0 +1,21 @@
import test from "node:test";
import assert from "node:assert/strict";
import { serializeTrack, serializeTracks } from "../src/web/serializers.js";
test("serializeTrack removes internal filesystem fields", () => {
const result = serializeTrack({
id: "track-1",
title: "Test",
path: "/private/storage/test.mp3",
storedName: "test.mp3",
});
assert.deepEqual(result, { id: "track-1", title: "Test" });
});
test("serializeTracks handles an array and null tracks", () => {
assert.deepEqual(serializeTracks([{ id: "1", path: "/tmp/1" }]), [
{ id: "1" },
]);
assert.equal(serializeTrack(null), null);
});