1
0
mirror of https://github.com/sasjs/server.git synced 2026-04-09 23:23:13 +00:00

feat(studio): run selected code + open in studio

This commit is contained in:
Saad Jutt
2021-12-16 12:14:32 +05:00
parent da11c03d55
commit 27129a8921
7 changed files with 204 additions and 14 deletions

View File

@@ -1,5 +1,5 @@
import express from 'express'
import { executeProgramRawValidation } from '../../utils'
import { executeProgramRawValidation, runSASValidation } from '../../utils'
import { STPController } from '../../controllers/'
import { FileUploadController } from '../../controllers/internal'
@@ -24,6 +24,22 @@ stpRouter.get('/execute', async (req, res) => {
}
})
stpRouter.post('/run', async (req, res) => {
const { error, value: body } = runSASValidation(req.body)
if (error) return res.status(400).send(error.details[0].message)
try {
const response = await controller.runSAS(req, body)
res.send(response)
} catch (err: any) {
const statusCode = err.code
delete err.code
res.status(statusCode).send(err)
}
})
stpRouter.post(
'/execute',
fileUploadController.preuploadMiddleware,