1
0
mirror of https://github.com/sasjs/server.git synced 2026-01-11 08:20:04 +00:00

feat: implemented api for renaming file/folder

This commit is contained in:
2022-07-20 23:45:11 +05:00
parent 48688a6547
commit fdcaba9d56
4 changed files with 144 additions and 3 deletions

View File

@@ -13,7 +13,8 @@ import {
fileParamValidation,
folderBodyValidation,
folderParamValidation,
isZipFile
isZipFile,
renameBodyValidation
} from '../../utils'
const controller = new DriveController()
@@ -232,6 +233,19 @@ driveRouter.patch(
}
)
driveRouter.post('/rename', async (req, res) => {
const { error, value: body } = renameBodyValidation(req.body)
if (error) return res.status(400).send(error.details[0].message)
try {
const response = await controller.rename(body)
res.send(response)
} catch (err: any) {
res.status(403).send(err.toString())
}
})
driveRouter.get('/fileTree', async (req, res) => {
try {
const response = await controller.getFileTree()