From 268035da9e77256b1312de5bf1b884e2669c4bfd Mon Sep 17 00:00:00 2001 From: legonzaur Date: Tue, 30 May 2023 20:43:21 +0200 Subject: [PATCH] fix X-File-Size header --- src/client/client.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/client/client.ts b/src/client/client.ts index 096b382..806482d 100644 --- a/src/client/client.ts +++ b/src/client/client.ts @@ -101,7 +101,7 @@ router.get('/:dataType', const dataType = req.params.dataType as keyof typeof path const selection = data.select([sum('kills').as('kills'), sum('deaths').as('deaths'), sum('deaths_with_weapon').as('deaths_while_equipped'), path[dataType], sum('total_distance').as('total_distance'), max('max_distance').as('max_distance')]).groupBy(path[dataType]) - const test = (await selection.execute()).reduce>((acc, curr) => { + const result = (await selection.execute()).reduce>((acc, curr) => { acc[curr[path[dataType]]] = { kills: Number(curr.kills), deaths: Number(curr.deaths), @@ -111,7 +111,10 @@ router.get('/:dataType', } return acc }, {}) - res.send(test) + const dataString = JSON.stringify(result) + const buffer = Buffer.from(dataString) + const size = buffer.length + res.status(200).setHeader('X-File-Size', size).setHeader('Content-Type', 'application/json').send(buffer) })() })