# @skills17/task-config-api

> Provides an API for task config and local history.

Latest version **2.0.0** (published 2021-12-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install @skills17/task-config-api
pnpm add @skills17/task-config-api
yarn add @skills17/task-config-api
bun add @skills17/task-config-api
```

Provides the command `skills17-task-config-api`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2021-12-03 |
| First published | 2021-02-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 13.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Cyril Wanner |
| Maintainers | cyrilwanner, skills17 |

## Links

- npm: https://www.npmjs.com/package/@skills17/task-config-api
- Repository: https://github.com/skills17/task-config-api
- Homepage: https://github.com/skills17/task-config-api#readme
- Issues: https://github.com/skills17/task-config-api/issues
- npm.io page: https://npm.io/package/@skills17/task-config-api

## Dependencies (5)

- [uniqid](https://npm.io/package/uniqid.md) ^5.3.0
- [express](https://npm.io/package/express.md) ^4.17.1
- [js-yaml](https://npm.io/package/js-yaml.md) ^4.1.0
- [minimist](https://npm.io/package/minimist.md) ^1.2.5
- [@skills17/task-config](https://npm.io/package/@skills17/task-config.md) ^3.0.1

## Recent versions

- 2.0.0 (latest) — 2021-12-03
- 1.0.1 — 2021-02-22
- 1.0.0 — 2021-02-20

## README

# skills17/task-config-api

This package provides an API for the task config and local history for environments where filesystem
access is not possible, such as within a browser.

## Table of contents

- [Installation](#installation)
  - [Production environment](#production-environment)
- [Usage](#usage)
  - [CLI](#cli)
  - [API Endpoints](#api-endpoints)
- [License](#license)

## Installation

For local development, simply run the following command in the task directory:
```bash
npx @skills17/task-config-api
```

The API will then serve the task from the current directory at `http://localhost:4500/:taskId` where
`taskId` is the `id` field from the `config.json` file.

### Production environment

For the production competition environment, it is suggested to install this package once globally
and let one instance handle all tasks. This is more performant than running separate instances for
multiple tasks.

To do so, install this package globally:
```bash
npm install -g @skills17/task-config-api
```

After that, run the globally installed `skills17-task-config-api` command and specify the directories
of all tasks that should be served.
```bash
skills17-task-config-api /path/to/task1 /path/to/task2 /path/to/task3 ...
```

## Usage

### CLI

```
  Usage
    $ skills17-task-config-api [options] [task directories...]

    If no task directory is specified, the current directory will be used.

  Options
    --port, -p   Specify the port [Default=4500]
    --bind, -b   Specify where the server will be bound [Default=127.0.0.1]
```

### API Endpoints

The following API endpoints will be available. The `taskId` parameter is the `id` field from the
`config.json` file of the targeted task.

#### `GET /:taskId/config.json`

Returns the `config.json` file of the path.
It has not been processed and is exactly the version present in the filesystem.

This can later be passed to a `@skills17/task-cconfig` instance in the `load(config)` method.

#### `POST /:taskId/history`

Will create a new entry in the local history if that feature is available.
If the feature is disabled, the response will be `{"created": false}`, otherwise true will be
returned after a successful entry.

The request needs to have a `application/json` content type and the body will be stored in the
history file.
Additionally, a `time` field will be added to the body before saving the file.
For example, if the body is `{"testResults":[...]}`, it will be saved as
`{"time":1613859061,"testResults":[...]}`.

## License

[MIT](https://github.com/skills17/task-config-api/blob/master/LICENSE)

---
_Source: https://npm.io/package/@skills17/task-config-api · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
