Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: increased req body size #110

Merged
merged 2 commits into from
Mar 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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