<commit_before># nci rest api server

REST api server for [nci](https://github.com/node-ci/nci).


## Installation

```sh
npm install nci-rest-api-server
```


## Usage

To enable add this plugin to the `plugins` section at server config:

```json
{
    "plugins": [
        "nci-rest-api-server"
    ],
    "http": {
        "host": "127.0.0.1",
        "port": 3000,
        "url": "http://127.0.0.1:3000"
    },
....
}
```

after that you can access api according to your server `http.host` and
`http.port` options.


## API routes

Notes:

 - Currently destructive api methods (project removing/renaming)
protected by randomly generated token which will be printed to the server log
during server startup.
 - Currently server respond format is only json.


### GET /api/0.1/builds

Get builds sorted by date in descending order.

Query parameters:
 - `project` - optional project filter
 - `limit` - maximum builds count to get (20 by default)


### GET /api/0.1/builds/:id

Get particular build by id.


### POST /api/0.1/builds
<commit_msg>update note about token at readme<commit_after># nci rest api server

REST api server for [nci](https://github.com/node-ci/nci).


## Installation

```sh
npm install nci-rest-api-server
```


## Usage

To enable add this plugin to the `plugins` section at server config:

```json
{
    "plugins": [
        "nci-rest-api-server"
    ],
    "http": {
        "host": "127.0.0.1",
        "port": 3000,
        "url": "http://127.0.0.1:3000"
    },
....
}
```

after that you can access api according to your server `http.host` and
`http.port` options.


## API routes

Notes:

 - Currently destructive api methods (project removing/renaming)
protected by token which could be set at config (`http.apiAccessToken` field)
or will be generated and printed to the server log during server startup.
Client should send token as `token` field at request body.
 - Currently server respond format is only json.


### GET /api/0.1/builds

Get builds sorted by date in descending order.

Query parameters:
 - `project` - optional project filter
 - `limit` - maximum builds count to get (20 by default)


### GET /api/0.1/builds/:id

Get particular build by id.


### POST /api/0.1/builds

{'fraction_non_alphanumeric': 0.12871287128712872, 'fraction_numerical': 0.025202520252025202, 'mean_word_length': 2.9982014388489207, 'pattern_counts': {'":': 10, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3885558', 'n_tokens_mistral': 756, 'n_tokens_neox': 695, 'n_words': 259}