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

chore(routes): change files route with drive

This commit is contained in:
Yury Shkoda
2021-10-28 12:09:19 +00:00
parent 49c152a398
commit 48fe7994ec
3 changed files with 7 additions and 7 deletions

35
src/routes/api/drive.ts Normal file
View File

@@ -0,0 +1,35 @@
import express from 'express'
import { createFileTree, getTreeExample } from '../../controllers'
import { isFileTree } from '../../types'
const driveRouter = express.Router()
driveRouter.post('/deploy', async (req, res) => {
if (!isFileTree(req.body.fileTree)) {
res.status(400).send({
status: 'failure',
message: 'Provided not supported data format.',
example: getTreeExample()
})
return
}
await createFileTree(
req.body.fileTree.members,
req.body.appLoc ? req.body.appLoc.replace(/^\//, '').split('/') : []
)
.then(() => {
res.status(200).send({
status: 'success',
message: 'Files deployed successfully to @sasjs/server.'
})
})
.catch((err) => {
res
.status(500)
.send({ status: 'failure', message: 'Deployment failed!', ...err })
})
})
export default driveRouter