Skip to content

Commit

Permalink
Remove unused dependency.
Browse files Browse the repository at this point in the history
  • Loading branch information
viferga committed Apr 9, 2024
1 parent b420ccf commit d51e339
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 83 deletions.
64 changes: 0 additions & 64 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
"dotenv": "^16.0.3",
"express": "^4.18.2",
"git-clone": "^0.2.0",
"p-queue-es5": "^6.0.2",
"unzipper": "^0.10.11"
},
"devDependencies": {
Expand All @@ -102,4 +101,4 @@
"prettier": "^2.1.2",
"typescript": "^4.3.2"
}
}
}
24 changes: 7 additions & 17 deletions src/controller/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import * as path from 'path';

import busboy from 'busboy';
import { NextFunction, Request, Response } from 'express';
import PQueue from 'p-queue-es5';
import { Extract } from 'unzipper';

import { currentFile, namearg } from '../constants';
Expand All @@ -30,24 +29,15 @@ const getUploadError = (on: keyof busboy.BusboyEvents): AppError => {

export default (req: Request, res: Response, next: NextFunction): void => {
const bb = busboy({ headers: req.headers });
const queue = new PQueue({ concurrency: 1 });

const handleError = (fn: () => void, on: keyof busboy.BusboyEvents) => {
queue
.add(() => {
try {
fn();
} catch (e) {
req.unpipe(bb);
queue.pause();
next(getUploadError(on));
}
})
.catch(err => {
req.unpipe(bb);
queue.pause();
next(err);
});
try {
fn();
} catch (e) {
console.error(e);
req.unpipe(bb);
next(getUploadError(on));
}
};

bb.on('file', (name, file, info) => {
Expand Down

0 comments on commit d51e339

Please sign in to comment.