Docs - Config

Applications written with Raddish are required to create a config.json which needs to be send to Raddish before starting. Below I will give an example config file, with more detail underneath.

copy
{
    "db": {
        "default": {
            "host": "localhost",
            "port": 3306,
            "user": "root",
            "password": "root",
            "database": "demo",
            "prefix": "demo_"
        }
    },
    "router" : {
        "cors": {
            "origin": "localhost",
            "methods": ["GET", "HEAD"],
            "credentials": false,
            "headers": ""
        },
        "routes": {
            "/foos": "/demo/menu/items",
            "/bar/:id": "/demo/menu/item",
            "/baz/*": "/templates/css/",
        }
    },
    "ssl": {
        "key": "./ssl.key",
        "cert": "./ss.crt"
    },
    "threads": {
        "maxThreads": 16,
        "maxThreshold": 50,
        "minThreshold": 10,
        "interval": 500
    },
    "socketio": {
        "port": 1338
    },
    "logging": {
        "adapter": "file",
        "options": {
            "file": "/logs/raddish.log"
        }
    },
    "cache": true,
    "format": "json",
    "gzip": true,
    "plugins": "/plugins",
    "port": 1337,
    "public": "/public"
}
db
This object hold all the database connection information. By default behavior the "default" connection needs to be present. This one will be used when no other database connection is specified.
router

The router object holds the values for CORS requests, and hold custom defined routers. May the CORS values be clear for them selves otherwise you can check here: CORS Specification.

The routes however are something different. There are redirects and state urls, I will try to explain.

Simple complete url redirects: This is as simple as doing: "/foos": "/demo/menu/items"

For automatic dynamic states you can do: "/bar/:id": "/demo/menu/item" In this case the state id will automatically be set when available.

For complete redirects you can add: "/baz/*": "/templates/css/" This will redirect everything with "/baz/" to /templates/css/.

ssl
This setting can only be false or an object.
When false (or not defined) ssl will not be started.
When it is an object key and cert are required and must point to the of the ssl key and ssl certificate files.
Threads

Can be true, false, not defined or an object,
when true it will start threads with the default values.
When an object it will override the default values with your custom values, displayed here are the default values.

The maxThreshold and minThreshold is the amount of usage a process might have before an extra thread is started or removed.
The interval is the interval in millisecond when the system must check for process usage.

socketio

The value can be true, an object, false or not defined.

When true it will start sockets on port 1338, when an object you can manually set the port to start on.

logging

With the logging object you can specify a logging object. Whenever an error is thrown the RaddishError object will log to this object.

For more details read here.

plugins
Specify the path to the plugins directory. When not defined plugins will not be used in the system.
cache
This value can be true, false or not defined. When true it will cache the initialized objects resulting in a huge speed advantage. When false or not defined the system will not cache any objects.
gzip
Enable gzip compression or not. When the client doesn't support gzip compression the result isn't compressed.
format *
Specify the default returned value.
port *
Specify on which port the system starts.
public *
Specify the folder where the public files are stored.
* = required