use formidable instead
This commit is contained in:
parent
23ad352088
commit
b8406ecaa4
3 changed files with 29 additions and 15 deletions
|
@ -25,6 +25,7 @@
|
|||
"@bull-board/api": "^4.6.4",
|
||||
"@bull-board/koa": "^4.6.4",
|
||||
"@bull-board/ui": "^4.6.4",
|
||||
"@cutls/megalodon": "5.1.15",
|
||||
"@discordapp/twemoji": "14.0.2",
|
||||
"@elastic/elasticsearch": "7.17.0",
|
||||
"@koa/cors": "3.4.3",
|
||||
|
@ -37,12 +38,11 @@
|
|||
"@tensorflow/tfjs": "^4.2.0",
|
||||
"ajv": "8.11.2",
|
||||
"archiver": "5.3.1",
|
||||
"koa-body": "^6.0.1",
|
||||
"autobind-decorator": "2.4.0",
|
||||
"autolinker": "4.0.0",
|
||||
"axios": "^1.3.2",
|
||||
"autwh": "0.1.0",
|
||||
"aws-sdk": "2.1277.0",
|
||||
"axios": "^1.3.2",
|
||||
"bcryptjs": "2.4.3",
|
||||
"blurhash": "1.1.5",
|
||||
"bull": "4.10.2",
|
||||
|
@ -71,6 +71,7 @@
|
|||
"jsonld": "6.0.0",
|
||||
"jsrsasign": "10.6.1",
|
||||
"koa": "2.13.4",
|
||||
"koa-body": "^6.0.1",
|
||||
"koa-bodyparser": "4.3.0",
|
||||
"koa-favicon": "2.1.0",
|
||||
"koa-json-body": "5.3.0",
|
||||
|
@ -79,7 +80,7 @@
|
|||
"koa-send": "5.0.1",
|
||||
"koa-slow": "2.1.0",
|
||||
"koa-views": "7.0.2",
|
||||
"@cutls/megalodon": "5.1.15",
|
||||
"koa2-formidable": "^1.0.3",
|
||||
"mfm-js": "0.23.2",
|
||||
"mime-types": "2.1.35",
|
||||
"multer": "1.4.4-lts.1",
|
||||
|
|
|
@ -6,6 +6,7 @@ import Koa from "koa";
|
|||
import Router from "@koa/router";
|
||||
import multer from "@koa/multer";
|
||||
import bodyParser from "koa-bodyparser";
|
||||
const formidable = require('koa2-formidable')
|
||||
import cors from "@koa/cors";
|
||||
import { apiMastodonCompatible } from './mastodon/ApiMastodonCompatibleService.js';
|
||||
import { Instances, AccessTokens, Users } from "@/models/index.js";
|
||||
|
@ -23,15 +24,6 @@ import twitter from "./service/twitter.js";
|
|||
// Init app
|
||||
const app = new Koa();
|
||||
|
||||
// Init multer instance
|
||||
const upload = multer({
|
||||
storage: multer.diskStorage({}),
|
||||
limits: {
|
||||
fileSize: config.maxFileSize || 262144000,
|
||||
files: 1,
|
||||
},
|
||||
});
|
||||
|
||||
app.use(
|
||||
cors({
|
||||
origin: "*",
|
||||
|
@ -44,6 +36,8 @@ app.use(async (ctx, next) => {
|
|||
await next();
|
||||
});
|
||||
|
||||
app.use(formidable());
|
||||
|
||||
app.use(
|
||||
bodyParser({
|
||||
// リクエストが multipart/form-data でない限りはJSONだと見なす
|
||||
|
@ -55,9 +49,14 @@ app.use(
|
|||
}),
|
||||
);
|
||||
|
||||
app.use(
|
||||
upload.any()
|
||||
);
|
||||
// Init multer instance
|
||||
const upload = multer({
|
||||
storage: multer.diskStorage({}),
|
||||
limits: {
|
||||
fileSize: config.maxFileSize || 262144000,
|
||||
files: 1,
|
||||
},
|
||||
});
|
||||
|
||||
// Init router
|
||||
const router = new Router();
|
||||
|
@ -71,6 +70,7 @@ for (const endpoint of [...endpoints, ...compatibility]) {
|
|||
if (endpoint.meta.requireFile) {
|
||||
router.post(
|
||||
`/${endpoint.name}`,
|
||||
upload.single("file"),
|
||||
handler.bind(null, endpoint),
|
||||
);
|
||||
} else {
|
||||
|
|
|
@ -164,6 +164,7 @@ importers:
|
|||
koa-send: 5.0.1
|
||||
koa-slow: 2.1.0
|
||||
koa-views: 7.0.2
|
||||
koa2-formidable: ^1.0.3
|
||||
mfm-js: 0.23.2
|
||||
mime-types: 2.1.35
|
||||
mocha: 10.2.0
|
||||
|
@ -278,6 +279,7 @@ importers:
|
|||
koa-send: 5.0.1
|
||||
koa-slow: 2.1.0
|
||||
koa-views: 7.0.2_6tybghmia4wsnt33xeid7y4rby
|
||||
koa2-formidable: 1.0.3
|
||||
mfm-js: 0.23.2
|
||||
mime-types: 2.1.35
|
||||
multer: 1.4.4-lts.1
|
||||
|
@ -6370,6 +6372,11 @@ packages:
|
|||
dependencies:
|
||||
fetch-blob: 3.2.0
|
||||
|
||||
/formidable/1.2.6:
|
||||
resolution: {integrity: sha512-KcpbcpuLNOwrEjnbpMC0gS+X8ciDoZE1kkqzat4a8vrprf+s9pKNQ/QIwWfbfs4ltgmFl3MD177SNTkve3BwGQ==}
|
||||
deprecated: 'Please upgrade to latest, formidable@v2 or formidable@v3! Check these notes: https://bit.ly/2ZEqIau'
|
||||
dev: false
|
||||
|
||||
/formidable/2.1.1:
|
||||
resolution: {integrity: sha512-0EcS9wCFEzLvfiks7omJ+SiYJAiD+TzK4Pcw1UlUoGnhUxDcMKjt0P7x8wEb0u6OHu8Nb98WG3nxtlF5C7bvUQ==}
|
||||
dependencies:
|
||||
|
@ -8381,6 +8388,12 @@ packages:
|
|||
- supports-color
|
||||
dev: false
|
||||
|
||||
/koa2-formidable/1.0.3:
|
||||
resolution: {integrity: sha512-m80sje/vb4mvhZn7HbZPwYHnsGjKL+oJ4OasNbH+jdvjIddVMPmugmmBwPnMYDGaMnL0tT9mJrfKRcp8MMdNyQ==}
|
||||
dependencies:
|
||||
formidable: 1.2.6
|
||||
dev: false
|
||||
|
||||
/ky-universal/0.10.1_ky@0.30.0:
|
||||
resolution: {integrity: sha512-r8909k+ELKZAxhVA5c440x22hqw5XcMRwLRbgpPQk4JHy3/ddJnvzcnSo5Ww3HdKdNeS3Y8dBgcIYyVahMa46g==}
|
||||
engines: {node: '>=14'}
|
||||
|
|
Loading…
Reference in a new issue