mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-24 16:03:02 +00:00
style: format server and shared with prettier
A mechanical prettier --write over server/src, server/tests, server/scripts and shared/src with the workspaces' .prettierrc; nothing but layout and import order changes, and every file keeps the same set of imports. shared is formatted throughout and its format baseline is empty. The server baseline keeps the 35 files that Prettier would grow past their lint:size limit (they need a split first, which is not a formatting change), and the generated entity files stay as their generator writes them.
This commit is contained in:
@@ -51,7 +51,7 @@ export async function readCappedJson<T>(res: CappedResponse, maxBytes: number):
|
||||
// Neither a stream nor text() means there is nothing to read incrementally
|
||||
// and nothing to cap — a null-body status, or a partial stub in a test.
|
||||
if (!res.body?.getReader && !res.text && !res.arrayBuffer && res.json) {
|
||||
return await res.json() as T;
|
||||
return (await res.json()) as T;
|
||||
}
|
||||
const { text, truncated } = await readCappedText(res, maxBytes);
|
||||
if (truncated) return undefined;
|
||||
@@ -69,7 +69,10 @@ export async function readCappedJson<T>(res: CappedResponse, maxBytes: number):
|
||||
* degrade to whatever they find. Responses without a stream fall back to
|
||||
* arrayBuffer(), which is post-checked instead.
|
||||
*/
|
||||
export async function readCapped(res: CappedResponse, maxBytes: number): Promise<{ bytes: Buffer; truncated: boolean }> {
|
||||
export async function readCapped(
|
||||
res: CappedResponse,
|
||||
maxBytes: number,
|
||||
): Promise<{ bytes: Buffer; truncated: boolean }> {
|
||||
const reader = res.body?.getReader();
|
||||
if (!reader) {
|
||||
const raw = res.arrayBuffer ? Buffer.from(await res.arrayBuffer()) : Buffer.from(res.text ? await res.text() : '');
|
||||
@@ -102,7 +105,10 @@ export async function readCapped(res: CappedResponse, maxBytes: number): Promise
|
||||
* stream it reads text() directly instead of going through readCapped, which
|
||||
* prefers arrayBuffer().
|
||||
*/
|
||||
export async function readCappedText(res: CappedResponse, maxBytes: number): Promise<{ text: string; truncated: boolean }> {
|
||||
export async function readCappedText(
|
||||
res: CappedResponse,
|
||||
maxBytes: number,
|
||||
): Promise<{ text: string; truncated: boolean }> {
|
||||
if (!res.body?.getReader && res.text) {
|
||||
const raw = Buffer.from(await res.text(), 'utf8');
|
||||
return raw.length > maxBytes
|
||||
|
||||
Reference in New Issue
Block a user