#12 audit and history
This commit is contained in:
@@ -16,7 +16,7 @@ class GameObjectsController{
|
||||
* @param {App} app The application instance, апликация
|
||||
*/
|
||||
init(app){
|
||||
const { gameObject } = app;
|
||||
const { gameObject, am } = app;
|
||||
const router = express.Router();
|
||||
|
||||
/**
|
||||
@@ -27,11 +27,14 @@ class GameObjectsController{
|
||||
router.put('/', multipartMiddleware, async (req, res)=>{
|
||||
try{
|
||||
let data = req.body;
|
||||
let object = await gameObject[data.id? 'update' : 'create'](req, data)
|
||||
let action = data.id ? 'update' : 'create';
|
||||
let object = await gameObject[action](req, data)
|
||||
res.json({status: 'OK', object});
|
||||
am.audit(req, `game-object-${action}`, object.id);
|
||||
}catch(err){
|
||||
console.error(err);
|
||||
res.status(500).json({status: 'ERR', err});
|
||||
am.audit(req, `game-object-alter-error`, req.body?.id, {q: req.body, e: err});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -44,6 +47,7 @@ class GameObjectsController{
|
||||
router.post('/', async (req, res)=>{
|
||||
let result = await gameObject.list(req.body);
|
||||
res.json(result);
|
||||
am.audit(req, `game-object-list`, null, {q: req.body});
|
||||
})
|
||||
|
||||
/**
|
||||
@@ -56,6 +60,7 @@ class GameObjectsController{
|
||||
router.get('/:id', async (req, res)=>{
|
||||
let object = await gameObject.read(parseInt(req.params.id));
|
||||
res.json(object);
|
||||
am.audit(req, `game-object-read`, object.id);
|
||||
})
|
||||
|
||||
/**
|
||||
@@ -67,6 +72,7 @@ class GameObjectsController{
|
||||
router.delete('/:id', async (req, res)=>{
|
||||
await gameObject.remove(req.params.id);
|
||||
res.json({status: 'OK'});
|
||||
am.audit(req, `game-object-delete`, req.params.id);
|
||||
})
|
||||
|
||||
app.webServer.xapp.use(this.route, router);
|
||||
|
||||
Reference in New Issue
Block a user