Server-side modules to be used by bebras tasks.
Some bebras tasks, for instance alkindi-task-enigma have both a client side and a server side ; the server side will generate data for the instance of the task, and send to the client side some of that data, hints and grade the answers, without revealing the full data to the user. bebras-server-modules is the intermediate between the client and the server for these tasks ; it handles communication, authentication, data storage and other features for these tasks.
- Install a recent version of node.js (tested with version 10 ; doesn't work with some older versions)
- Create a MySQL database for bebras-server-modules
- Create a
.envconfiguration file using.env.exampleas template (check documentation below) yarn installyarn build- Install pm2 globally :
yarn global add pm2
You must first add task modules to bebras-server-modules (for instance, the server-modules from alkindi-task-enigma. You can do so with :
yarn cmd tasks:add TASK_ID TASK_PATH
with TASK_ID being an unique identifier for the task, and TASK_PATH the absolute path to the js file of the module.
You can then start the servers :
./pm2_start_all.sh
If you kept the default port, the endpoint you will need to make your client tasks point at will be http://your.server:3101/ ; note that bebras-server-modules doesn't offer any user interface.
Base configuration is done in the .env file ; use .env.example as template.
DEV_MODE: settruefor dev purposes only. It will skip the verification of tokens, and allow to send an object astaskargument instead of a token.DB_variables : settings to connect to the MySQL databaseSTORAGE: set tolocalto save files locally,s3to save files on S3STORAGE_PATH: folder in which saved assets will be stored, if you useSTORAGE=localS3_variables : settings to access S3, if you useSTORAGE=s3STORAGE_URL: URL to access assets storedTOKENS_SERVICE_URL: URL to access the tokens service of bebras-server-modulesTASKS_GRADER_KEY_FILE: private key to sign tokens, the default demo one can be used for development purposes
During development, you can use the following command to restart automatically the tasks endpoint of bebras-server-modules each time a file in the task module tasks/enigma/ is modified :
npx pm2 start --no-daemon --watch tasks/enigma/ dist/server.js --name bsm-tasks --interpreter babel-node -- tasks -p=3101
Adapt the watched path to the task you're working on.
- Add task :
yarn cmd tasks:add TASK_ID TASK_PATH - Remove task :
yarn cmd tasks:remove TASK_ID - Show all tasks :
yarn cmd tasks:list - Clear all tasks :
yarn cmd tasks:clear - Clear expired data :
yarn cmd data:clear - Stop all servers :
./pm2_stop_all.sh