annotations
This commit is contained in:
@@ -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'});
|
||||
|
||||
@@ -1,12 +1,59 @@
|
||||
import express from 'express';
|
||||
|
||||
/**
|
||||
* GamesController. API for the games manager
|
||||
*/
|
||||
class GamesController{
|
||||
|
||||
name = 'gamesApi'
|
||||
route = '/api/game'
|
||||
|
||||
/**
|
||||
* Initializes the GamesController plugin
|
||||
* @param {App} app The application instance
|
||||
*/
|
||||
init(app){
|
||||
const router = express.Router();
|
||||
const { games } = app;
|
||||
|
||||
/**
|
||||
* API: PUT /api/game/ Create or update game
|
||||
* @function createOrUpdate
|
||||
* @memberof GamesController
|
||||
*/
|
||||
router.put('/', async (req, res)=>{
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* API: POST /api/game/ List games by given criteria
|
||||
* @function list
|
||||
* @returns {Game[]}
|
||||
* @memberof GamesController
|
||||
*/
|
||||
router.post('/', async (req, res)=>{
|
||||
})
|
||||
|
||||
/**
|
||||
* API: GET /api/game/:id Retrieve game by ID
|
||||
* @function read
|
||||
* @param {string} id The id of the game
|
||||
* @returns {Game}
|
||||
* @memberof GamesController
|
||||
*/
|
||||
router.get('/:id', async (req, res)=>{
|
||||
})
|
||||
|
||||
/**
|
||||
* API: DELETE /api/game/:id Delete game by ID
|
||||
* @function remove
|
||||
* @param {string} id The id of the game
|
||||
* @memberof GamesController
|
||||
*/
|
||||
router.delete('/:id', async (req, res)=>{
|
||||
})
|
||||
|
||||
app.webServer.xapp.use(this.route, router);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
import express from 'express';
|
||||
|
||||
/**
|
||||
* RulesController. API for the game rules manager
|
||||
*/
|
||||
class RulesController{
|
||||
|
||||
name = 'rulesApi'
|
||||
route = '/api/rule'
|
||||
|
||||
/**
|
||||
* Initializes the RulesController plugin
|
||||
* @param {App} app The application instance
|
||||
*/
|
||||
init(app){
|
||||
const router = express.Router();
|
||||
const { rules } = app;
|
||||
|
||||
/**
|
||||
* API: PUT /api/rule/ Create or update rule
|
||||
* @function createOrUpdate
|
||||
* @memberof RulesController
|
||||
*/
|
||||
router.put('/', async (req, res)=>{
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* API: POST /api/rule/ List rules by given criteria
|
||||
* @function list
|
||||
* @returns {Rule[]}
|
||||
* @memberof RulesController
|
||||
*/
|
||||
router.post('/', async (req, res)=>{
|
||||
})
|
||||
|
||||
/**
|
||||
* API: GET /api/rule/:id Retrieve rule by ID
|
||||
* @function read
|
||||
* @param {string} id The id of the rule
|
||||
* @returns {Rule}
|
||||
* @memberof RulesController
|
||||
*/
|
||||
router.get('/:id', async (req, res)=>{
|
||||
})
|
||||
|
||||
/**
|
||||
* API: DELETE /api/rule/:id Delete rule by ID
|
||||
* @function remove
|
||||
* @param {string} id The id of the rule
|
||||
* @memberof RulesController
|
||||
*/
|
||||
router.delete('/:id', async (req, res)=>{
|
||||
})
|
||||
|
||||
app.webServer.xapp.use(this.route, router);
|
||||
}
|
||||
}
|
||||
|
||||
export { RulesController }
|
||||
@@ -0,0 +1,60 @@
|
||||
import express from 'express';
|
||||
|
||||
/**
|
||||
* ScenariosController. API for the scenarios manager
|
||||
*/
|
||||
class ScenariosController{
|
||||
|
||||
name = 'scenariosApi'
|
||||
route = '/api/scenario'
|
||||
|
||||
/**
|
||||
* Initializes the ScenariosController plugin
|
||||
* @param {App} app The application instance
|
||||
*/
|
||||
init(app){
|
||||
const router = express.Router();
|
||||
const { scenarios } = app;
|
||||
|
||||
/**
|
||||
* API: PUT /api/scenario/ Create or update scenario
|
||||
* @function createOrUpdate
|
||||
* @memberof ScenariosController
|
||||
*/
|
||||
router.put('/', async (req, res)=>{
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* API: POST /api/scenario/ List scenarios by given criteria
|
||||
* @function list
|
||||
* @returns {Scenario[]}
|
||||
* @memberof ScenariosController
|
||||
*/
|
||||
router.post('/', async (req, res)=>{
|
||||
})
|
||||
|
||||
/**
|
||||
* API: GET /api/scenario/:id Retrieve scenario by ID
|
||||
* @function read
|
||||
* @param {string} id The id of the scenario
|
||||
* @returns {Scenario}
|
||||
* @memberof ScenariosController
|
||||
*/
|
||||
router.get('/:id', async (req, res)=>{
|
||||
})
|
||||
|
||||
/**
|
||||
* API: DELETE /api/scenario/:id Delete scenario by ID
|
||||
* @function remove
|
||||
* @param {string} id The id of the scenario
|
||||
* @memberof ScenariosController
|
||||
*/
|
||||
router.delete('/:id', async (req, res)=>{
|
||||
})
|
||||
|
||||
app.webServer.xapp.use(this.route, router);
|
||||
}
|
||||
}
|
||||
|
||||
export { ScenariosController }
|
||||
Reference in New Issue
Block a user