scaffolding

This commit is contained in:
2024-11-12 16:22:30 +02:00
parent 7180cfeb7f
commit c2245d92b3
9 changed files with 345 additions and 2 deletions
+102
View File
@@ -0,0 +1,102 @@
/**
* Games manager class
*/
class GamesManager{
name = 'games';
/**
* Class initializer
* @param {App} app Class initializer
*/
init(app){
const {db} = app;
/**
* Creates a new game definition
* @param {Context} ctx Request context
* @param {Game} data the game description
*/
this.create = async function(ctx, data){
}
/**
* Reads game definition by ID
* @param {Number} id game ID
* @returns {Game}
*/
this.read = async function(id){
}
/**
* Updates game definition
* @param {Context} ctx Request context
* @param {Game} data the game description
*/
this.update = async function(ctx, data){
}
/**
* Removes game by ID
* @param {Number} id game definition ID
*/
this.remove = async function(id){
}
/**
* Returns a set of games by given criteria
* @param {Query} query criteria
* @returns {Game[]}
*/
this.list = async function(query){
}
}
/**
* Class starter
* @param {App} app The application
*/
async start(app){
}
}
/**
* Game entity
*/
class Game {
/**
* Game name
* @type string
*/
name = null;
/**
* Game formal description
* @type GameDefinition
*/
definition = {
/**
*
*/
levels:[
{
name: 'Level 1',
environment: null,
objects:[
{
id: 15
}
]
}
]
};
}
export { GamesManager }
+82
View File
@@ -0,0 +1,82 @@
/**
* Rules manager class
*/
class RulesManager{
name = 'rules';
/**
* Class initializer
* @param {App} app Class initializer
*/
init(app){
const {db} = app;
/**
* Creates a new rule
* @param {Context} ctx Request context
* @param {Rule} data the rule
*/
this.create = async function(ctx, data){
}
/**
* Reads rule by ID
* @param {Number} id rule ID
* @returns {Rule}
*/
this.read = async function(id){
}
/**
* Updates rule
* @param {Context} ctx Request context
* @param {Rule} data the rule
*/
this.update = async function(ctx, data){
}
/**
* Removes rule by ID
* @param {Number} id rule ID
*/
this.remove = async function(id){
}
/**
* Returns a set of rules by given criteria
* @param {Query} query criteria
* @returns {Rule[]}
*/
this.list = async function(query){
}
}
/**
* Class starter
* @param {App} app The application
*/
async start(app){
}
}
/**
* Rule entity
*/
class Rule {
/**
* Rule name
* @type string
*/
name = null;
}
export { RulesManager }
+82
View File
@@ -0,0 +1,82 @@
/**
* Scenarios manager class
*/
class ScenariosManager{
name = 'scenarios';
/**
* Class initializer
* @param {App} app Class initializer
*/
init(app){
const {db} = app;
/**
* Creates a new scenario
* @param {Context} ctx Request context
* @param {Scenario} data the scenario
*/
this.create = async function(ctx, data){
}
/**
* Reads scenario by ID
* @param {Number} id scenario ID
* @returns {Scenario}
*/
this.read = async function(id){
}
/**
* Updates scenario
* @param {Context} ctx Request context
* @param {Scenario} data the scenario
*/
this.update = async function(ctx, data){
}
/**
* Removes scenario by ID
* @param {Number} id scenario ID
*/
this.remove = async function(id){
}
/**
* Returns a set of scenarios by given criteria
* @param {Query} query criteria
* @returns {Scenario[]}
*/
this.list = async function(query){
}
}
/**
* Class starter
* @param {App} app The application
*/
async start(app){
}
}
/**
* Scenario entity
*/
class Scenario {
/**
* Scenario name
* @type string
*/
name = null;
}
export { ScenariosManager }
@@ -0,0 +1,13 @@
import express from 'express';
class GamesController{
name = 'gamesApi'
route = '/api/game'
init(app){
const router = express.Router();
}
}
export { GamesController }