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

feat(deploy): add route to deploy a file tree to @sasjs/server

This commit is contained in:
Yury Shkoda
2021-07-09 08:27:15 +03:00
parent c71a08f1d2
commit b4bf72f704
6 changed files with 135 additions and 48 deletions

View File

@@ -1,6 +1,6 @@
import express from 'express'
import { processSas } from '../controllers'
import { ExecutionResult, RequestQuery, isRequestQuery } from '../types'
import { processSas, createFileTree, getTreeExample } from '../controllers'
import { ExecutionResult, isRequestQuery, isFileTree } from '../types'
const router = express.Router()
@@ -20,4 +20,20 @@ router.get('/', async (req, res) => {
<p>Log:</p> <textarea style="width: 100%; height: 100%">${result.log}</textarea>`)
})
router.post('/deploy', async (req, res) => {
if (!isFileTree(req.body)) {
res.status(400).send(getTreeExample())
return
}
await createFileTree(req.body.members)
.then(() => {
res.status(200).send('Files deployed successfully to @sasjs/server.')
})
.catch((err) => {
res.status(500).send({ message: 'Deployment failed!', ...err })
})
})
export default router