From 6dc39c0d91ac13d6d9b8c0a2240446bfc45bdd7f Mon Sep 17 00:00:00 2001 From: Saad Jutt Date: Mon, 28 Mar 2022 04:53:24 +0500 Subject: [PATCH 1/2] fix: increased req body size --- api/src/app.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/app.ts b/api/src/app.ts index 0416d3e4..a49f0c64 100644 --- a/api/src/app.ts +++ b/api/src/app.ts @@ -34,7 +34,7 @@ if (MODE?.trim() !== 'server' || CORS?.trim() === 'enable') { app.use(cookieParser()) app.use(morgan('tiny')) -app.use(express.json({ limit: '50mb' })) +app.use(express.json({ limit: '100mb' })) app.use(express.static(path.join(__dirname, '../public'))) const onError: ErrorRequestHandler = (err, req, res, next) => { From 0a5aeceab560b022197d0c30c3da7f091b261b1e Mon Sep 17 00:00:00 2001 From: Saad Jutt Date: Mon, 28 Mar 2022 05:05:03 +0500 Subject: [PATCH 2/2] fix: DELETE req cannot have body --- api/public/swagger.yaml | 12 +----------- api/src/app.ts | 1 - api/src/controllers/drive.ts | 16 ++-------------- api/src/routes/api/drive.ts | 5 ++--- 4 files changed, 5 insertions(+), 29 deletions(-) diff --git a/api/public/swagger.yaml b/api/public/swagger.yaml index 0e3f52f5..8367ae1e 100644 --- a/api/public/swagger.yaml +++ b/api/public/swagger.yaml @@ -649,7 +649,6 @@ paths: required: - status type: object - description: "It's optional to either provide `_filePath` in url as query parameter\nOr provide `filePath` in body as form field.\nBut it's required to provide else API will respond with Bad Request." summary: 'Delete file from SASjs Drive' tags: - Drive @@ -660,19 +659,10 @@ paths: - in: query name: _filePath - required: false + required: true schema: type: string example: /Public/somefolder/some.file - requestBody: - required: false - content: - multipart/form-data: - schema: - type: object - properties: - filePath: - type: string post: operationId: SaveFile responses: diff --git a/api/src/app.ts b/api/src/app.ts index a49f0c64..0634dcac 100644 --- a/api/src/app.ts +++ b/api/src/app.ts @@ -10,7 +10,6 @@ import { copySASjsCore, getWebBuildFolderPath, loadAppStreamConfig, - sasJSCoreMacros, setProcessVariables } from './utils' diff --git a/api/src/controllers/drive.ts b/api/src/controllers/drive.ts index 1b116847..bccd41e5 100644 --- a/api/src/controllers/drive.ts +++ b/api/src/controllers/drive.ts @@ -108,20 +108,14 @@ export class DriveController { } /** - * It's optional to either provide `_filePath` in url as query parameter - * Or provide `filePath` in body as form field. - * But it's required to provide else API will respond with Bad Request. * * @summary Delete file from SASjs Drive * @query _filePath Location of SAS program * @example _filePath "/Public/somefolder/some.file" */ @Delete('/file') - public async deleteFile( - @Query() _filePath?: string, - @FormField() filePath?: string - ) { - return deleteFile((_filePath ?? filePath)!) + public async deleteFile(@Query() _filePath: string) { + return deleteFile(_filePath) } /** @@ -305,9 +299,3 @@ const updateFile = async ( return { status: 'success' } } - -const validateFilePath = async (filePath: string) => { - if (!(await fileExists(filePath))) { - throw 'DriveController: File does not exists.' - } -} diff --git a/api/src/routes/api/drive.ts b/api/src/routes/api/drive.ts index bd6af296..db0ce5de 100644 --- a/api/src/routes/api/drive.ts +++ b/api/src/routes/api/drive.ts @@ -57,12 +57,11 @@ driveRouter.get('/file', async (req, res) => { driveRouter.delete('/file', async (req, res) => { const { error: errQ, value: query } = fileParamValidation(req.query) - const { error: errB, value: body } = fileBodyValidation(req.body) - if (errQ && errB) return res.status(400).send(errQ.details[0].message) + if (errQ) return res.status(400).send(errQ.details[0].message) try { - const response = await controller.deleteFile(query._filePath, body.filePath) + const response = await controller.deleteFile(query._filePath) res.send(response) } catch (err: any) { res.status(403).send(err.toString())