<commit_before># Content Service

This service exposes information about beacons, and their associated content,
and channels.


## With Docker

The easiest way to get started is to go to the root of the `magnet-services`
directory, and run `docker compose up`.  If you make a change to the code,
you'll need to rebuild the container image if you're running inside a
container.

## Without Docker

To run locally for development use: `npm run-script start-dev`, this will start
the server outside of a container and run `nodemon`. Make sure the database is
up and configured in `database.json`, see the top level README for instructions
on starting a database for development.

## Migrations

Migrations use `db-migrate`. Ensure `database.json`
has the correct connection info for your environment and run `db-migrate up`.

This is done for you if you use `npm start`.

## API

#### POST `/v1/channel`

Authenticate with an api key set in the `X-ApiKey` header.

Creates a new `channel`.

Body must be content type `application/json` and contain the following fields:

```JSON
{
  name: '<unique name of channel>',
  email: '<unique email address>',
  tags: '<associated descriptive tags:optional>'
}
```

#### POST `/v1/channel/:name/beacons`

Authenticate with an api key set in the `X-ApiKey` header.

Creates a new `beacon` resource.

Body must be content type `application/json` and contain the following fields
(see comments for optional fields):

```JSON
{
  location: { lat: <number>, long: <number> }, // Optional unless is_virtual is
  true
  is_virtual: <boolean>,<commit_msg>Formatting<commit_after># Content Service

This service exposes information about beacons, and their associated content,
and channels.


## With Docker

The easiest way to get started is to go to the root of the `magnet-services`
directory, and run `docker compose up`.  If you make a change to the code,
you'll need to rebuild the container image if you're running inside a
container.

## Without Docker

To run locally for development use: `npm run-script start-dev`, this will start
the server outside of a container and run `nodemon`. Make sure the database is
up and configured in `database.json`, see the top level README for instructions
on starting a database for development.

## Migrations

Migrations use `db-migrate`. Ensure `database.json`
has the correct connection info for your environment and run `db-migrate up`.

This is done for you if you use `npm start`.

## API

#### POST `/v1/channel`

Authenticate with an api key set in the `X-ApiKey` header.

Creates a new `channel`.

Body must be content type `application/json` and contain the following fields:

```JS
{
  name: '<unique name of channel>',
  email: '<unique email address>',
  tags: '<associated descriptive tags:optional>'
}
```

#### POST `/v1/channel/:name/beacons`

Authenticate with an api key set in the `X-ApiKey` header.

Creates a new `beacon` resource.

Body must be content type `application/json` and contain the following fields
(see comments for optional fields):

```JS
{
  location: { lat: <number>, long: <number> }, // Optional unless is_virtual is
  true
  is_virtual: <boolean>,
{'fraction_non_alphanumeric': 0.0909952606635071, 'fraction_numerical': 0.001263823064770932, 'mean_word_length': 4.321008403361344, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '1327421', 'n_tokens_mistral': 918, 'n_tokens_neox': 891, 'n_words': 441}