Skip to content

Server-side (NodeJS based) implementation of the architecture (no modules included)

License

Notifications You must be signed in to change notification settings

server-state/server-base

Repository files navigation

server-base

Build Status GitHub npm version

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.

Example

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