mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
framework: allow empty file upload
This commit is contained in:
3 files changed
+7
-5
No files matched your search
@@ -190,7 +190,7 @@ export class ApiHandler<C extends Context> extends Handler<C> {
|
|||||||
if (!['get', 'post'].includes(this.request.method.toLowerCase())) {
|
if (!['get', 'post'].includes(this.request.method.toLowerCase())) {
|
||||||
throw new MethodNotAllowedError(this.request.method);
|
throw new MethodNotAllowedError(this.request.method);
|
||||||
}
|
}
|
||||||
if (!APIS[op]) throw new BadRequestError('Invalid operation');
|
if (!APIS[op]) throw new BadRequestError(`Invalid API operation: ${op}`);
|
||||||
if (APIS[op].type === 'Subscription') {
|
if (APIS[op].type === 'Subscription') {
|
||||||
throw new BadRequestError('Subscription operation cannot be called in HTTP handler');
|
throw new BadRequestError('Subscription operation cannot be called in HTTP handler');
|
||||||
}
|
}
|
||||||
@@ -226,7 +226,7 @@ export class ApiConnectionHandler<C extends Context> extends ConnectionHandler<C
|
|||||||
this.isRpc = true;
|
this.isRpc = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!APIS[op]) throw new BadRequestError('Invalid operation');
|
if (!APIS[op]) throw new BadRequestError(`Invalid API operation: ${op}`);
|
||||||
if (APIS[op].type !== 'Subscription') {
|
if (APIS[op].type !== 'Subscription') {
|
||||||
throw new BadRequestError('Only subscription operations are supported');
|
throw new BadRequestError('Only subscription operations are supported');
|
||||||
}
|
}
|
||||||
@@ -250,7 +250,7 @@ export class ApiConnectionHandler<C extends Context> extends ConnectionHandler<C
|
|||||||
throw new BadRequestError('Invalid message');
|
throw new BadRequestError('Invalid message');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!APIS[message.op]) throw new BadRequestError('Invalid operation');
|
if (!APIS[message.op]) throw new BadRequestError(`Invalid API operation: ${message.op}`);
|
||||||
if (APIS[message.op].type !== 'Subscription') {
|
if (APIS[message.op].type !== 'Subscription') {
|
||||||
throw new BadRequestError('Only subscription operations are supported');
|
throw new BadRequestError('Only subscription operations are supported');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/framework",
|
"name": "@hydrooj/framework",
|
||||||
"version": "0.2.4",
|
"version": "0.2.5",
|
||||||
"main": "index.ts",
|
"main": "index.ts",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": "https://github.com/hydro-dev/Hydro",
|
"repository": "https://github.com/hydro-dev/Hydro",
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
"@mongodb-js/saslprep": "^1.3.2",
|
"@mongodb-js/saslprep": "^1.3.2",
|
||||||
"emoji-regex": "^10.6.0",
|
"emoji-regex": "^10.6.0",
|
||||||
"fs-extra": "^11.3.2",
|
"fs-extra": "^11.3.2",
|
||||||
"koa": "^3.0.3",
|
"koa": "^3.1.1",
|
||||||
"koa-body": "^7.0.0",
|
"koa-body": "^7.0.0",
|
||||||
"koa-compress": "^5.1.1",
|
"koa-compress": "^5.1.1",
|
||||||
"path-to-regexp": "^8.3.0",
|
"path-to-regexp": "^8.3.0",
|
||||||
|
|||||||
@@ -412,6 +412,8 @@ ${c.response.status} ${endTime - startTime}ms ${c.response.length}`);
|
|||||||
formLimit: '8mb',
|
formLimit: '8mb',
|
||||||
formidable: {
|
formidable: {
|
||||||
uploadDir,
|
uploadDir,
|
||||||
|
allowEmptyFiles: true,
|
||||||
|
minFileSize: 0,
|
||||||
maxFileSize: parseMemoryMB(this.config.upload) * 1024 * 1024,
|
maxFileSize: parseMemoryMB(this.config.upload) * 1024 * 1024,
|
||||||
keepExtensions: true,
|
keepExtensions: true,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in new issue
Block a user