Skip to content

Commit

Permalink
Merge pull request #110 from sasjs/issue-108
Browse files Browse the repository at this point in the history
fix: increased req body size
  • Loading branch information
allanbowe authored Mar 28, 2022
2 parents 117a53c + 0a5aece commit f8e1522
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 30 deletions.
12 changes: 1 addition & 11 deletions api/public/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions api/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
copySASjsCore,
getWebBuildFolderPath,
loadAppStreamConfig,
sasJSCoreMacros,
setProcessVariables
} from './utils'

Expand All @@ -34,7 +33,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) => {
Expand Down
16 changes: 2 additions & 14 deletions api/src/controllers/drive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

/**
Expand Down Expand Up @@ -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.'
}
}
5 changes: 2 additions & 3 deletions api/src/routes/api/drive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit f8e1522

Please sign in to comment.