annotations

This commit is contained in:
2024-11-27 12:46:03 +02:00
parent 54b8941f3c
commit ad4eef17f5
12 changed files with 514 additions and 36 deletions
@@ -2,17 +2,27 @@ import express from 'express';
import multipart from 'connect-multiparty';
const multipartMiddleware = multipart();
/**
* GameObjectsController. API for the game objects manager
*/
class GameObjectsController{
name = 'gameObjectsApi'
route = '/api/game-object'
/**
* Initializes the GameObjectsController plugin
* @param {App} app The application instance
*/
init(app){
const { gameObject } = app;
const router = express.Router();
/**
* Create & update
* API: PUT /api/game-object/ Create or update game object
* @function createOrUpdate
* @memberof GameObjectsController
*/
router.put('/', multipartMiddleware, async (req, res)=>{
try{
@@ -26,22 +36,34 @@ class GameObjectsController{
});
/**
* List
* API: POST /api/game-object/ List game objects by given criteria
* @function list
* @returns {GameObject[]}
* @memberof GameObjectsController
*/
router.post('/', async (req, res)=>{
let result = await gameObject.list(req.body);
res.json(result);
})
router.get('/', async (req, res)=>{
})
/**
* API: GET /api/game-object/:id Retrieve game object by ID
* @function read
* @param {string} id The id of the game object
* @returns {GameObject}
* @memberof GameObjectsController
*/
router.get('/:id', async (req, res)=>{
let object = await gameObject.read(parseInt(req.params.id));
res.json(object);
})
/**
* API: DELETE /api/game-object/:id Delete game object by ID
* @function remove
* @param {string} id The id of the game object
* @memberof GameObjectsController
*/
router.delete('/:id', async (req, res)=>{
await gameObject.remove(req.params.id);
res.json({status: 'OK'});