Comparing version 0.1.3 to 0.1.4
{ | ||
"name": "minoss", | ||
"title": "Mini Node Script Server", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "Mini Node Script Server - Simple API Server with auto-loading, abstraction and configuration handling for IoT automation.", | ||
@@ -35,2 +35,3 @@ "main": "server.js", | ||
"dependencies": { | ||
"body-parser": "^1.15.2", | ||
"express": "^4.14.0", | ||
@@ -41,3 +42,3 @@ "js2xmlparser": "^2.0.2" | ||
"gulp": "^3.9.1", | ||
"gulp-jshint": "^1.12.0", | ||
"gulp-jshint": "^2.0.1", | ||
"jshint-stylish": "^2.2.1" | ||
@@ -44,0 +45,0 @@ }, |
# Minoss - Mini Node Script Server | ||
[![GitHub version](https://badge.fury.io/gh/eisbehr-%2Fminoss.svg)](http://github.com/eisbehr-/minoss) | ||
[![NPM version](https://badge.fury.io/js/minoss.svg)](http://www.npmjs.org/package/minoss) | ||
[![Dependency version](https://david-dm.org/eisbehr-/minoss.png)](https://david-dm.org/eisbehr-/minoss) | ||
This is a small yet powerful server based on [`node.js`](https://nodejs.org) and [`express`](http://expressjs.com). | ||
@@ -65,7 +69,7 @@ It's designed to simple create and serve usable APIs for automatising things, like with the [`Raspberry Pi`](https://www.raspberrypi.org/) or whenever it's needed to easily execute scripts. | ||
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 | ||
| 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 | ||
@@ -94,5 +98,3 @@ | ||
```TEXT | ||
$ Minoss now listening on http://localhost:8080 ... | ||
``` | ||
> Minoss now listening on http://localhost:8080 ... | ||
@@ -126,5 +128,3 @@ | ||
```TEXT | ||
http://localhost:8080/{MODULE}/{SCRIPT} | ||
``` | ||
> http://localhost:8080/{MODULE}/{SCRIPT} | ||
@@ -141,7 +141,5 @@ | ||
```TEXT | ||
http://localhost:8080/module/script | ||
http://localhost:8080/json/module/script | ||
http://localhost:8080/module/script?output=json | ||
``` | ||
> http://localhost:8080/module/script | ||
> http://localhost:8080/**json**/module/script | ||
> http://localhost:8080/module/script?output=**json** | ||
@@ -160,6 +158,4 @@ Will output something like: | ||
```TEXT | ||
http://localhost:8080/xml/module/script | ||
http://localhost:8080/module/script?output=xml | ||
``` | ||
> http://localhost:8080/**xml**/module/script | ||
> http://localhost:8080/module/script?output=**xml** | ||
@@ -179,6 +175,4 @@ Will output something like: | ||
```TEXT | ||
http://localhost:8080/text/module/script | ||
http://localhost:8080/module/script?output=text | ||
``` | ||
> http://localhost:8080/**text**/module/script | ||
> http://localhost:8080/module/script?output=**text** | ||
@@ -228,8 +222,8 @@ The `text` output format will return `1` on success and `0` on failure. | ||
name | type | description | ||
---------|-----------|-------------- | ||
config | object | contains all configurations for this module | ||
params | object | contains all parameters given by request url | ||
respond | function | callback function for browser response | ||
error | function | callback function for errors | ||
| name | type | description | ||
| :------ | :------- | :----------- | ||
| config | object | contains all configurations for this module | ||
| params | object | contains all parameters given by request url | ||
| respond | function | callback function for browser response | ||
| error | function | callback function for errors | ||
@@ -236,0 +230,0 @@ |
@@ -16,2 +16,3 @@ /** | ||
var app = require("express")(); | ||
var parser = require("body-parser"); | ||
var config = require("./config/server"); | ||
@@ -24,2 +25,6 @@ var routes = require("./config/routes"); | ||
// handle request data else than GET | ||
app.use(parser.json()); | ||
app.use(parser.urlencoded({extended: true})); | ||
// register custom routes | ||
@@ -26,0 +31,0 @@ routes(app); |
@@ -213,5 +213,5 @@ "use strict"; | ||
catch(e) { | ||
return false | ||
return false; | ||
} | ||
} | ||
}; |
@@ -22,9 +22,11 @@ "use strict"; | ||
request: function(req, res) { | ||
var requestObj = req.method === "GET" ? req.query : req.body; | ||
// store output format into params | ||
if( !req.query.output ) { | ||
req.query.output = req.params.output || "json"; | ||
if( !requestObj.output ) { | ||
requestObj.output = req.params.output || "json"; | ||
} | ||
var module = req.query.module = req.params.module; | ||
var script = req.query.script = req.params.script; | ||
var module = requestObj.module = req.params.module; | ||
var script = requestObj.script = req.params.script; | ||
@@ -45,3 +47,3 @@ // clean console on debug and track execution time | ||
moduleConfig, | ||
req.query, | ||
requestObj, | ||
handler.respond.bind({req: req, res: res}), | ||
@@ -48,0 +50,0 @@ handler.error.bind({req: req, res: res}) |
33045
542
3
375
+ Addedbody-parser@^1.15.2