1
0
mirror of https://github.com/sasjs/server.git synced 2026-01-13 17:00:06 +00:00

chore(drive): post new file route added

This commit is contained in:
Saad Jutt
2021-11-13 16:39:20 +05:00
parent 04a8626570
commit a4ac5dc280
3 changed files with 92 additions and 0 deletions

View File

@@ -35,6 +35,23 @@ driveRouter.get('/file', async (req, res) => {
}
})
driveRouter.post('/file', async (req, res) => {
const { error, value: body } = updateFileDriveValidation(req.body)
if (error) return res.status(400).send(error.details[0].message)
const controller = new DriveController()
try {
const response = await controller.saveFile(body)
res.send(response)
} catch (err: any) {
const statusCode = err.code
delete err.code
res.status(statusCode).send(err)
}
})
driveRouter.patch('/file', async (req, res) => {
const { error, value: body } = updateFileDriveValidation(req.body)
if (error) return res.status(400).send(error.details[0].message)