Skip to content

Instantly share code, notes, and snippets.

@amitava82
Last active August 29, 2015 14:08
Show Gist options
  • Save amitava82/3b1722e4925630bdd72b to your computer and use it in GitHub Desktop.
Save amitava82/3b1722e4925630bdd72b to your computer and use it in GitHub Desktop.
dns router readme

dns router configuration

Guide to configuring dns router

dns.json configuration

Each domain or subdoman has a configuration object which looks like this:

{
  "type": "lookup",
  "fallback": {

  }
}
  • type: explicit - use configuration defied in the file. lookup - lookup in redis
  • fallback: define a fallback route configuration object explained below.

Route definition

Route definition object is a configuration object that is used in dns router to handle a request.

  • auth: If the route require authentication
  • routes: object containing keys for different request type and route configuration object value

###Route configuration object

  • type: possible values: redirect, display, action. redirect will redirect request to url defined in redirect. If set to display then controller and action is ignored, returns view (Is preRender flo invoked and passed to view if present?). action is default which invokes controller action.
  • view: path to jade view file
  • action: controller action to invoke
  • controller: controller where the action is defined
  • redirect: URL to redirect if type is set to redirect
  • stack: middleware stack to run through
  • permissions: array of permission id. If auth is set to true then user permission will be checked with allowed permissions.
  • preRender: flo to invoke before render. Data returned from flo will be passed to view as flodata object
  • postRender: flo to invoke after render.. use case?
  • viewData: arbitrary data object passed to req.instance
{
    "auth": false,
    "routes": {
        "get": {
            "type": "",
            "action": "",
            "controller": "",
            "stack": "",
            "redirect": "",
            "permissions":[],
            "postRender": "flo2",
            "preRender": "flo1",
            "viewData":{}

        },
        "post": {
            "validate": true,
            "validationRules": {
                "onFail": "Field a is required",
                "rule": ""
            }
        }
    }
}
@nikhilhasija
Copy link

the post Render use case is where the Flo is injected to the page so that it is called upon page load over an ajax call. This would mean that an api.js file be included and on page load the api call will be made asynchronously to this address. This address might require a jwt token to be passed so that permissions can be explicitly invoked through a pre-authed token vs. a system account which has access to everything. This would also allow non-session based handling to occur by simple API injection in the front-end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment