Server-side (NodeJS based) implementation of the server-base architecture (no modules included).
It manages server modules and can get attached to an express app, where it creates routes under /api/v1/
, as specified in https://specs.server-state.tech/#/api/server-base.
let app; // An express app
const ServerState = require('@server-state/server-base');
const server = new ServerState({
logToConsole: true, // Log error messages to console, ...
logToFile: false // ... but not to a file
});
// Add module under name 'raw'. Will add it to /api/v1/all and create /api/v1/raw
server.addModule('raw', require('@server-state/raw-module'), ['guest'], [
'ls',
'whoami'
]);
server.init(app); // Attach the server-state server to the express app
app.listen(8080); // "Start" the express app