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

feat: improved deploy and execute endpoints

This commit is contained in:
Yury Shkoda
2021-09-30 14:39:54 +03:00
parent c4b9402f01
commit 5b4e5626fc
3 changed files with 82 additions and 52 deletions

View File

@@ -22,25 +22,51 @@ router.get('/', async (req, res) => {
router.post('/deploy', async (req, res) => {
if (!isFileTree(req.body)) {
res.status(400).send(getTreeExample())
res.status(400).send({
status: 'failure',
message: 'Provided not supported data format.',
example: getTreeExample()
})
return
}
await createFileTree(req.body.members)
.then(() => {
res.status(200).send('Files deployed successfully to @sasjs/server.')
res.status(200).send({
status: 'success',
message: 'Files deployed successfully to @sasjs/server.'
})
})
.catch((err) => {
res.status(500).send({ message: 'Deployment failed!', ...err })
res
.status(500)
.send({ status: 'failure', message: 'Deployment failed!', ...err })
})
})
router.post('/execute', async (req, res) => {
if (req.body?._program) {
const result: ExecutionResult = await processSas(req.body)
await processSas(req.body)
.then((result) => {
res.status(200).send({
status: 'success',
message: 'Job has been sent for execution.',
...result
})
})
.catch((err) => {
res.status(400).send({
status: 'failure',
message: 'Job execution failed.',
error: err
})
})
} else {
res.status(400).send(`Please provide the location of SAS code`)
res.status(400).send({
status: 'failure',
message: `Please provide the location of SAS code`
})
}
})