Closed IARKI closed 4 years ago
Hello @IARKI,
Have you the same version between @tsed/multer and @tsed/common ?
do you mean @tsed/multipartfiles"? "@tsed/multipartfiles": "^5.44.6", "@tsed/common": "^5.44.6"
Same error happens if I use @UseBefore(AnyMiddleware, {data: "anydata"})
If that is helpful
So the problem isn't about multer but about UseAuth and UseBefore. I'll check that.
I cannot reproduce. The example here https://github.com/TypedProject/tsed/tree/production/examples/multer works as expected (I added a UseBefore decorator). Can you checkout this example and try it.
If your problem persist, can you give me a reproductible repository example please :)
See you Romain
updating to 5.44.9 fixed the issue It looks like https://github.com/TypedProject/tsed/commit/3f36f91381b14f6be30e57601453e983518ef461 fixed the issue
Thanks
still this issue occur after upgrading to 5.44.9
@gangasiddhi can you checkout this example: https://github.com/TypedProject/tsed/tree/production/examples/multer and try it. If you haven’t problems, can you give me a reproductible repository example please :)
And am not able to see the upload option in the swagger.
import { Controller, Status, Post } from '@tsed/common';
import { MultipartFile } from '@tsed/multipartfiles';
//import {Responses} from "@tsed/swagger";
//import { csvFileService } from './../services/uploadFIle';
@Controller('/')
export class saltgroupController {
constructor(private csvFileService: csvFileService) {}
@Post('/files')
@Status(201)
@Responses("201", {description: "Uploaded"})
async getData(@MultipartFile("file") file: Express.Multer.File): Promise<any> {
return true;
}
}
@ServerSettings({
//server settings need to be implemented
rootDir,
httpPort: config.get<number>('server.port'),
httpsPort: false,
mount: {
'/': `${rootDir}/controllers/**/*.ts`
},
uploadDir: `${rootDir}/uploaded-files`,
swagger: [
{
path: '/docs'
}
],
multer: {
dest: `${rootDir}/uploaded-files`
},
acceptMimes: ['application/json','multipart/form-data'],
componentsScan: [
'${rootDir}/services/**/*.ts',
'${rootDir}/middlewares/**/*.ts',
'${rootDir}/interfaces/**/*.ts'
// "${rootDir}/tests/**/*.ts"
]
})
With the official example, the upload file appear:
And based on your example, I have the same result.
I can't reproduce your problem. So if you give an access to your repository (or a repository with only the necessary code to reproduce the problem), I can take a look :)
See you, Romain
Still the same issue, i used the sample code as it is.
{
"name": "ABC",
"version": "2.0.0",
"description": "ABC",
"keywords": [],
"license": "ISC",
"author": "",
"main": "index.js",
"scripts": {
"start": "nps",
"test": "nps test"
},
"dependencies": {
"@tsed/common": "5.44.9",
"@tsed/core": "5.44.9",
"@tsed/di": "5.44.9",
"@tsed/logger": "^5.4.1",
"@tsed/multipartfiles": "^5.44.9",
"@tsed/swagger": "5.44.9",
"@types/papaparse": "^5.0.3",
"@types/request-promise-native": "^1.0.17",
"@types/swagger-schema-official": "^2.0.20",
"body-parser": "^1.19.0",
"compression": "^1.7.4",
"config": "^3.2.5",
"cors": "^2.8.5",
"express": "^4.17.1",
"helmet": "^3.21.2",
"jest-junit": "^10.0.0",
"knex": "^0.20.9",
"morgan": "^1.9.1",
"multer": "^1.4.2",
"objection": "^2.1.2",
"papaparse": "^5.1.1",
"pg": "^7.18.1",
"request": "^2.88.2",
"request-promise-native": "^1.0.8",
"source-map-support": "^0.5.16"
},
"devDependencies": {
"@tsed/testing": "^5.44.9",
"@types/compression": "^1.7.0",
"@types/config": "0.0.36",
"@types/cors": "^2.8.6",
"@types/express": "^4.17.2",
"@types/helmet": "0.0.45",
"@types/jest": "^25.1.3",
"@types/morgan": "^1.7.37",
"@types/node": "^13.9.1",
"@types/request-promise-native": "^1.0.17",
"@typescript-eslint/eslint-plugin": "^2.23.0",
"@typescript-eslint/parser": "^2.23.0",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.10.0",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-prettier": "^3.1.2",
"eslint-plugin-simple-import-sort": "^5.0.1",
"eslint-plugin-sonarjs": "^0.5.0",
"jest": "^25.1.0",
"nps": "^5.9.12",
"nps-utils": "^1.7.0",
"rimraf": "^3.0.2",
"ts-jest": "^25.2.1",
"tsc-watch": "^4.1.0",
"typescript": "^3.8.2",
"wait-on": "^4.0.0"
}
}
Ok now your problem is clear :). Multer package works as expected. Do you use webpack to run your server? What is executed by nps under the hood?
There is a know issue about stack based on webpack/jest (no espacially for Ts.ED, typeorm also has it). When you use this stack, you have to import all class (controller, etc,...) explicitly with ES6. Dynamic import won’t work (componantScan with globpattern).
Can you change your Server configuration please :)
I close this issue, the problem isn’t probably about @tsed/multipartfiles but from your stack. See you
npm install --save @types/multer, fixed the issue.
thanks @Romakita for the quick reply.
@gangasiddhi Ha ok :)
I'm interested by your stack based on jest. I working on the @tsed/cli and one of the feature, is to generate project based on Jest framework. It's possible to share a minimal repository on git based on your stack please :)?
See you Romain
Information
A few sentences describing the overall goals of the issue.
Example
On starting server I'm getting next error
If I remove
@MultipartFile("fileName") file: Express.Multer.File
everything works fine