old_contents: require('dotenv').config();
  
  var express = require('express');
  var app = express();
  var fs = require( 'fs' );
  var auth = require('basic-auth');
  var bodyParser = require('body-parser');
  
  app.use(bodyParser.json({
      type: '*/*'
  }));
  
  //authorization
  app.use(function(req, res, next) {
      var credentials = auth(req);
      if (!credentials || credentials.name !== process.env.API_USER || credentials.pass !== process.env.API_PASS) {
          res.set({
              'WWW-Authenticate': 'Basic realm="simple-admin"'
          });
          res.sendStatus(401);
      } else {
          next();
      }
  });
  
  routes = fs.readdirSync('./routes');
  routes.forEach( function( routeFile ) {
      app.use('/api/' + routeFile, require('./routes/' + routeFile));
  });
  
  function error(err, req, res, next) {
      console.error(err.stack);
      res.send(500);
  }
  app.use(error);
  
  var server = app.listen(process.env.RASPAPI_PORT, function() {
  
      var host = server.address().address;
      var port = server.address().port;
  
      console.log('raspapi listening at http://%s:%s', host, port);
  
  });
  
new_contents: require('dotenv').config();
  
  var express = require('express');
  var app = express();
  var fs = require( 'fs' );
  var auth = require('basic-auth');
  var bodyParser = require('body-parser');
  
  //parsing
  app.use(bodyParser.json({
      type: '*/*'
  }));
  
  //authorization
  app.use(function(req, res, next) {
      var credentials = auth(req);
      if (!credentials || credentials.name !== process.env.API_USER || credentials.pass !== process.env.API_PASS) {
          res.set({
              'WWW-Authenticate': 'Basic realm="simple-admin"'
          });
          res.sendStatus(401);
      } else {
          next();
      }
  });
  
  //pretty jsonresponses
  app.use(function(req, res, next) {
      res.sendStatusJson = function (status) {
          res.status(status).send({status: status});
      };
      next();
  });
  
  //routes
  routes = fs.readdirSync('./routes');
  routes.forEach( function( routeFile ) {
      app.use('/api/' + routeFile, require('./routes/' + routeFile));
  });
  
  //errorhandling
  app.use(function(err, req, res, next) {
      console.error(err.stack);
      res.status(500).send({
          error: "500"
      });
      next(err);
  });
  
  var server = app.listen(process.env.RASPAPI_PORT, function() {
  
      var host = server.address().address;
      var port = server.address().port;
  
      console.log('raspapi listening at http://%s:%s', host, port);
  
  });
  
subject: improve error and "status code only" responses to return json