Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion drop-base
6 changes: 4 additions & 2 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ export default defineNuxtConfig({

vite: {
plugins: [
tailwindcss(),
// eslint-disable-next-line @typescript-eslint/no-explicit-any
tailwindcss() as any,
// only used in dev server, not build because nitro sucks
// see build hook below
viteStaticCopy({
Expand All @@ -84,7 +85,8 @@ export default defineNuxtConfig({
dest: "twemoji",
},
],
}),
// eslint-disable-next-line @typescript-eslint/no-explicit-any
}) as any,
],
},

Expand Down
39 changes: 24 additions & 15 deletions server/api/v2/client/chunk.post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ const GetChunk = type({
files: type({
filename: "string",
chunkIndex: "number",
}).array(),
})
.array()
.atLeastLength(1)
.atMostLength(256),
}).configure(throwingArktype);

export default defineEventHandler(async (h3) => {
Expand Down Expand Up @@ -46,21 +49,27 @@ export default defineEventHandler(async (h3) => {
streamFiles.map((e) => e.end - e.start).join(","),
); // Non-standard header, but we're cool like that 😎

for (const file of streamFiles) {
const gameReadStream = await libraryManager.readFile(
context.libraryId,
context.libraryPath,
context.versionName,
file.filename,
{ start: file.start, end: file.end },
);
if (!gameReadStream)
throw createError({
statusCode: 500,
statusMessage: "Failed to create read stream",
});
const streams = await Promise.all(
streamFiles.map(async (file) => {
const gameReadStream = await libraryManager.readFile(
context.libraryId,
context.libraryPath,
context.versionName,
file.filename,
{ start: file.start, end: file.end },
);
if (!gameReadStream)
throw createError({
statusCode: 500,
statusMessage: "Failed to create read stream",
});
return { ...file, stream: gameReadStream };
}),
);

for (const file of streams) {
let length = 0;
await gameReadStream.pipeTo(
await file.stream.pipeTo(
new WritableStream({
write(chunk) {
h3.node.res.write(chunk);
Expand Down
2 changes: 1 addition & 1 deletion server/middleware/latency.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export default defineEventHandler(async () => {
// await new Promise((r) => setTimeout(r, 700));
// await new Promise((r) => setTimeout(r, 1400));
});