gamedesigner

This commit is contained in:
2025-03-19 18:45:40 +02:00
parent 86559bcacd
commit 73ca07bcc0
12 changed files with 367 additions and 25 deletions
+15 -2
View File
@@ -14,7 +14,7 @@ class GamesController{
*/
init(app){
const router = express.Router();
const { games } = app;
const { game } = app;
/**
* API: PUT /api/game/ Create or update game, създаване/обновяване на игрова дефиниция
@@ -22,7 +22,14 @@ class GamesController{
* @memberof GamesController
*/
router.put('/', async (req, res)=>{
try{
let data = req.body;
let object = await game[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 GamesController{
* @memberof GamesController
*/
router.post('/', async (req, res)=>{
let result = await game.list(req.body);
res.json(result);
})
/**
@@ -42,6 +51,8 @@ class GamesController{
* @memberof GamesController
*/
router.get('/:id', async (req, res)=>{
let object = await game.read(parseInt(req.params.id));
res.json(object);
})
/**
@@ -51,6 +62,8 @@ class GamesController{
* @memberof GamesController
*/
router.delete('/:id', async (req, res)=>{
await scenario.remove(req.params.id);
res.json({status: 'OK'});
})
app.webServer.xapp.use(this.route, router);