This commit is contained in:
David Négrier 2020-10-01 15:55:23 +02:00
parent d3fa901691
commit e4872c6f9d
4 changed files with 56 additions and 59 deletions

View file

@ -63,7 +63,7 @@ export class FileController extends BaseController {
console.log('READING FILE', fieldname)
const chunks: Buffer[] = []
for await (let chunk of file) {
for await (const chunk of file) {
if (!(chunk instanceof Buffer)) {
throw new Error('Unexpected chunk');
}
@ -101,7 +101,6 @@ export class FileController extends BaseController {
});
this.App.get("/download-audio-message/:id", (res: HttpResponse, req: HttpRequest) => {
(async () => {
this.addCorsHeaders(res);
res.onAborted(() => {
@ -154,8 +153,6 @@ export class FileController extends BaseController {
});
}
});
})();
});
}
}

View file

@ -31,7 +31,7 @@ const handleBody = (res: HttpResponse, req: HttpRequest) => {
if (contType.includes('application/json'))
res.json = async () => JSON.parse(await res.body());
if (contTypes.map(t => contType.indexOf(t) > -1).indexOf(true) > -1)
if (contTypes.map(t => contType.includes(t)).includes(true))
res.formData = formData.bind(res, contType);
};

View file

@ -15,7 +15,7 @@ function formData(
encoding: string,
mimetype: string
) => string;
onField?: (fieldname: string, value: any) => void;
onField?: (fieldname: string, value: any) => void; // eslint-disable-line @typescript-eslint/no-explicit-any
filename?: (oldName: string) => string;
} = {}
) {
@ -75,11 +75,11 @@ function formData(
}
function setRetValue(
ret: { [x: string]: any },
ret: { [x: string]: any }, // eslint-disable-line @typescript-eslint/no-explicit-any
fieldname: string,
value: { filename: string; encoding: string; mimetype: string; filePath?: string } | any
value: { filename: string; encoding: string; mimetype: string; filePath?: string } | any // eslint-disable-line @typescript-eslint/no-explicit-any
) {
if (fieldname.slice(-2) === '[]') {
if (fieldname.endsWith('[]')) {
fieldname = fieldname.slice(0, fieldname.length - 2);
if (Array.isArray(ret[fieldname])) {
ret[fieldname].push(value);

View file

@ -48,9 +48,9 @@ async function startOneUser(): Promise<void> {
connectionManager.initBenchmark();
for (let userNo = 0; userNo < 40; userNo++) {
for (let userNo = 0; userNo < 160; userNo++) {
startOneUser();
// Wait 0.5s between adding users
await sleep(500);
await sleep(125);
}
})();