add logging of images

main
qwertyforce 2022-07-21 15:57:03 +03:00
parent 5404ad3687
commit 1506ff8ed5
3 changed files with 25 additions and 23 deletions

18
package-lock.json generated
View File

@ -9,11 +9,11 @@
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"@fastify/busboy": "^1.1.0",
"@fastify/cors": "^8.0.0",
"@fastify/formbody": "^7.0.1",
"@fastify/multipart": "^7.1.0",
"@fastify/reply-from": "^8.1.0",
"@types/multiparty": "^0.0.33",
"@types/node": "^18.0.5",
"axios": "^0.27.2",
"cross-env": "^7.0.3",
@ -152,14 +152,6 @@
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.9.tgz",
"integrity": "sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ=="
},
"node_modules/@types/multiparty": {
"version": "0.0.33",
"resolved": "https://registry.npmjs.org/@types/multiparty/-/multiparty-0.0.33.tgz",
"integrity": "sha512-Il6cJUpSqgojT7NxbVJUvXkCblm50/yEJYtblISDsNIeNYf4yMAhdizzidUk6h8pJ8yhwK/3Fkb+3Dwcgtwl8w==",
"dependencies": {
"@types/node": "*"
}
},
"node_modules/@types/node": {
"version": "18.0.5",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.0.5.tgz",
@ -992,14 +984,6 @@
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.9.tgz",
"integrity": "sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ=="
},
"@types/multiparty": {
"version": "0.0.33",
"resolved": "https://registry.npmjs.org/@types/multiparty/-/multiparty-0.0.33.tgz",
"integrity": "sha512-Il6cJUpSqgojT7NxbVJUvXkCblm50/yEJYtblISDsNIeNYf4yMAhdizzidUk6h8pJ8yhwK/3Fkb+3Dwcgtwl8w==",
"requires": {
"@types/node": "*"
}
},
"@types/node": {
"version": "18.0.5",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.0.5.tgz",

View File

@ -19,11 +19,11 @@
},
"homepage": "https://github.com/qwertyforce/ambience#readme",
"dependencies": {
"@fastify/busboy": "^1.1.0",
"@fastify/cors": "^8.0.0",
"@fastify/formbody": "^7.0.1",
"@fastify/multipart": "^7.1.0",
"@fastify/reply-from": "^8.1.0",
"@types/multiparty": "^0.0.33",
"@types/node": "^18.0.5",
"axios": "^0.27.2",
"cross-env": "^7.0.3",

View File

@ -4,12 +4,30 @@ import fastify from 'fastify'
import formBodyPlugin from '@fastify/formbody'
import fastifyReplyFrom from '@fastify/reply-from'
import fastifyCors from '@fastify/cors'
// import multiparty from 'multiparty'
// import busboy from '@fastify/busboy'
// import fs from 'fs'
// import path from 'path'
const server = fastify({logger:true})
// server.addHook('preHandler', function (req, _reply, done) {
// var form = new multiparty.Form({autoFiles:true,uploadDir:"./uploads/"})
// form.parse(req.raw)
// server.addHook('onRequest', function (req, _reply, done) {
// console.log(req.raw)
// if (req.raw.headers['content-type'] && req.raw.headers['content-type'].includes("multipart/form-data;")) {
// const bb = busboy({
// headers: { "content-type": req.raw.headers['content-type'] }, limits: {
// fieldNameSize: 100, // Max field name size in bytes
// fieldSize: 10, // Max field value size in bytes
// fields: 10, // Max number of non-file fields
// fileSize: 50000000, // For multipart forms, the max file size in bytes //50MB
// files: 1, // Max number of file fields
// headerPairs: 2000 // Max number of header key=>value pairs
// }
// })
// bb.on('file', (_name, file, _info) => {
// const saveTo = path.join("./uploads", `${new Date().getTime()}.jpg`)
// file.pipe(fs.createWriteStream(saveTo))
// });
// req.raw.pipe(bb)
// }
// done()
// })
@ -35,7 +53,7 @@ server.register(async function (app) {
attachFieldsToBody: true,
limits: {
fieldNameSize: 100, // Max field name size in bytes
fieldSize: 1000, // Max field value size in bytes
fieldSize: 10, // Max field value size in bytes
fields: 10, // Max number of non-file fields
fileSize: 50000000, // For multipart forms, the max file size in bytes //50MB
files: 1, // Max number of file fields