This is a small yet powerful server based on node.js and express.
It's designed to simple create and serve usable APIs for automatising things, like with the Raspberry Pi or whenever it's needed to easily execute scripts.
Minoss is very easy to extend for your needs.
Build in it has a automatically file loading, handling abstractions and configurations on many levels. Just place the files on the right place and the Server will handle anything else.
- Installation
- Install Modules
- Configuration
- Start Minoss
- Call a Module-Script
- Output Formats
- Available Modules
- Create an own Module
- Configure a Module
- Overwrite Module Files
- Validate Scripts
- Bugs / Feature request
- License
- Donation
Minoss can easily be installed with npm.
$ npm install minossIf installed this way, it's only needed to require minoss in the starting script file.
Like in an own server.js file:
require('minoss');Another way is, inside a folder where wanted to install Minoss, just to download the project files.
It's possible to download the zip archive from GitHub or use git to download the latest files.
With this way the core files of Minoss are stored inside the root folder.
$ git clone https://github.com/dkern/minoss.git .If you want to use other public modules, the easiest way to install them is to use npm. For example:
$ npm install minoss-exampleMinoss itself only has a very small configuration.
You will find anything with a description inside the config/server.js file.
Change the options as you like.
| name | default | description |
|---|---|---|
| debug | false | enable debug mode to have a verbose console output |
| port | 8080 | port number to listen on after start |
| xmlRootTag | root | name of the xml root tag |
The routes.js configuration allows you to add own routes to the server.
Because Minoss is based on express you can use it's full routing functions.
module.exports = app => {
app.get('/example', (req, res) => {
res.send("example response");
});
}The server can be started one time by using npm start or manually by node server.js inside the directory where you installed it.
$ node server.jsAfter start a message should notice about where the server is listening by now.
Minoss now listening on http://localhost:8080 ...
You may want to let the server running forever and automatically start it after reboot or crash.
Therefore you could use pm2, a process manager for node.js.
If you didn't use pm2 already, you can install it globally.
$ npm install -g pm2Once installed you can add Minoss execution to the handling of pm2:
$ pm2 startup
$ pm2 start server.js --name minoss
$ pm2 saveAnd that's it, your server will now run automatically on every boot, pm2 will even restart Minoss when it crashes.
If you want to stop it with pm2 stop minoss.
You call and execute a script always by module and script name.
Minoss will do anything else for you.
Minoss supports three different output types by default: json, xml and plain text, while json is the default.
You can switch between them every time.
Just put the wanted output format before the module and script name, or append it as get parameter.
Possible calls:
http://localhost:8080/module/script
http://localhost:8080/**json**/module/script
http://localhost:8080/module/script?output=**json**
Will output something like:
{
"success": true
}Possible calls:
http://localhost:8080/**xml**/module/script
http://localhost:8080/module/script?output=**xml**
Will output something like:
<?xml version='1.0'?>
<minoss>
<success>true</success>
</minoss>Possible calls:
http://localhost:8080/**text**/module/script
http://localhost:8080/module/script?output=**text**
The text output format will return 1 on success and 0 on failure.
If an error message is available it will be return just the message itself.
So in short, everything not 1 is an error.
There are currently only a few modules available by myself. Feel free to create own Modules on your own or spread some new ones with other.
- minoss-example: An example module explaining how to create and use modules
- minoss-google-home: Plays audio files or TTS on Google Home devices
- minoss-hue: Controlling Philips Hue devices and lamps
- minoss-pushover: Create and send push notifications via PushOver
- minoss-telegram-bot: Adds a Telegram Bot to Minoss
Creating a module is just creating a new folder in the Minoss root directory. The name of the directory is the name of the module. Inside this directory all executable scripts takes place. The name of the Files are also the name of the script.
For example, when creating a folder and file named example/test.js, the module is named example and the dcript is named test.
So the URl would be something like http://hostname:8080/example/test.
More details and a full example can be found inside the minoss-example repository.
A Script must always export a function.
This function has four parameters, which will be filled by Minoss on request of this script.
module.exports = (config, params, respond, error) => {
respond(true);
};| name | type | description |
|---|---|---|
| config | object | contains all configurations for this module |
