link scenarios to backend

This commit is contained in:
2025-03-15 11:23:55 +02:00
parent 6aad752ce3
commit 2a44578430
13 changed files with 233 additions and 75 deletions
+14 -1
View File
@@ -22,7 +22,14 @@ class ScenariosController{
* @memberof ScenariosController
*/
router.put('/', async (req, res)=>{
try{
let data = req.body;
let object = await scenarios[data.id? 'update' : 'create'](req, data)
res.json({status: 'OK', object});
}catch(err){
console.error(err);
res.status(500).json({status: 'ERR', err});
}
});
/**
@@ -32,6 +39,8 @@ class ScenariosController{
* @memberof ScenariosController
*/
router.post('/', async (req, res)=>{
let result = await scenarios.list(req.body);
res.json(result);
})
/**
@@ -42,6 +51,8 @@ class ScenariosController{
* @memberof ScenariosController
*/
router.get('/:id', async (req, res)=>{
let object = await scenarios.read(parseInt(req.params.id));
res.json(object);
})
/**
@@ -51,6 +62,8 @@ class ScenariosController{
* @memberof ScenariosController
*/
router.delete('/:id', async (req, res)=>{
await gameObject.remove(req.params.id);
res.json({status: 'OK'});
})
app.webServer.xapp.use(this.route, router);