Skip to content

Commit 0ae4495

Browse files
committed
framework: allow empty file upload
1 parent 11b932c commit 0ae4495

3 files changed

Lines changed: 7 additions & 5 deletions

File tree

framework/framework/api.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ export class ApiHandler<C extends Context> extends Handler<C> {
190190
if (!['get', 'post'].includes(this.request.method.toLowerCase())) {
191191
throw new MethodNotAllowedError(this.request.method);
192192
}
193-
if (!APIS[op]) throw new BadRequestError('Invalid operation');
193+
if (!APIS[op]) throw new BadRequestError(`Invalid API operation: ${op}`);
194194
if (APIS[op].type === 'Subscription') {
195195
throw new BadRequestError('Subscription operation cannot be called in HTTP handler');
196196
}
@@ -226,7 +226,7 @@ export class ApiConnectionHandler<C extends Context> extends ConnectionHandler<C
226226
this.isRpc = true;
227227
return;
228228
}
229-
if (!APIS[op]) throw new BadRequestError('Invalid operation');
229+
if (!APIS[op]) throw new BadRequestError(`Invalid API operation: ${op}`);
230230
if (APIS[op].type !== 'Subscription') {
231231
throw new BadRequestError('Only subscription operations are supported');
232232
}
@@ -250,7 +250,7 @@ export class ApiConnectionHandler<C extends Context> extends ConnectionHandler<C
250250
throw new BadRequestError('Invalid message');
251251
}
252252
}
253-
if (!APIS[message.op]) throw new BadRequestError('Invalid operation');
253+
if (!APIS[message.op]) throw new BadRequestError(`Invalid API operation: ${message.op}`);
254254
if (APIS[message.op].type !== 'Subscription') {
255255
throw new BadRequestError('Only subscription operations are supported');
256256
}

framework/framework/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hydrooj/framework",
3-
"version": "0.2.4",
3+
"version": "0.2.5",
44
"main": "index.ts",
55
"license": "MIT",
66
"repository": "https://github.com/hydro-dev/Hydro",
@@ -13,7 +13,7 @@
1313
"@mongodb-js/saslprep": "^1.3.2",
1414
"emoji-regex": "^10.6.0",
1515
"fs-extra": "^11.3.2",
16-
"koa": "^3.0.3",
16+
"koa": "^3.1.1",
1717
"koa-body": "^7.0.0",
1818
"koa-compress": "^5.1.1",
1919
"path-to-regexp": "^8.3.0",

framework/framework/server.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,8 @@ ${c.response.status} ${endTime - startTime}ms ${c.response.length}`);
412412
formLimit: '8mb',
413413
formidable: {
414414
uploadDir,
415+
allowEmptyFiles: true,
416+
minFileSize: 0,
415417
maxFileSize: parseMemoryMB(this.config.upload) * 1024 * 1024,
416418
keepExtensions: true,
417419
},

0 commit comments

Comments
 (0)