# routes

By default, Kazana exposes these routes

```
# if `public` is set to a path, the assets in that
# folder are served at the root path
# if `public` is not configured in kazana manifest
# the root path is the same as /kazana
# serving the built-in default kazana app
# see https://github.com/eHealthAfrica/kazana/issues/195
GET /{path*}

# TOOD: static kazana information page
#       https://github.com/eHealthAfrica/kazana/issues/195
GET /kazana/{path*}

# TODO: returns JSON with version of app & kazana and meta information
#       https://github.com/eHealthAfrica/kazana-server/issues/117
GET /kazana/api

# account
# TODO: Extend API for account & user management
#       https://github.com/eHealthAfrica/kazana/issues/125
#       -> implements http://docs.accountjsonapi.apiary.io
GET /kazana/account/api/session
POST /kazana/account/api/session
DELETE /kazana/account/api/session

# raw data reports
# TODO: rename submissions to reports
#       https://github.com/eHealthAfrica/kazana-raw-data/issues/80
GET /kazana/raw-data/api/submissions
POST /kazana/raw-data/api/submissions
POST /kazana/raw-data/api/submissions/with-attachments
GET /kazana/raw-data/api/submissions/{id}
PUT /kazana/raw-data/api/submissions/{id}
DELETE /kazana/raw-data/api/submissions/{id}
PUT /kazana/raw-data/api/submissions/{id}/attachments
GET /kazana/raw-data/api/submissions/{id}/attachments/{filename}
PUT /kazana/raw-data/api/submissions/{id}/attachments/{filename}

# indicators
# TODO: https://github.com/eHealthAfrica/kazana/issues/172
GET /kazana/integrated-data/api/indicators
GET /kazana/integrated-data/api/indices/{name}

# entities
# {type} is plural
# WIP: https://github.com/eHealthAfrica/kazana/issues/145
GET /kazana/entities/api/{type}
POST /kazana/entities/api/{type}
GET /kazana/entities/api/{type}/{id}
PUT /kazana/entities/api/{type}/{id}
DELETE /kazana/entities/api/{type}/{id}
GET /kazana/entities/{path*} # generic entities management UI
```

## Custom routes

Custom routes can be set in the app’s or plugin’s [kazana-manifest](kazana-manifest#routes).
See hapi’s [server.route](http://hapijs.com/api#serverrouteoptions) API for
available options, including authentication, validation and parameters

## Authentication

All routes require a valid user session by default. A user is validated based
on the session ID passed as bearer token in the `Authrization` header:

```
Authorization: bearer {session id}
```

In order to make a route publically accessible, set `config.auth: false`
(see [Route options](http://hapijs.com/api#route-options))

```js
{
  method: 'GET',
  path: '/my/custom/path',
  config: {
    auth: false
  },
  handler: function (request, reply) {
    reply('Hello from /my/custom/path')
  }
}
```
