### [CI/CD pipelines](.github/workflows/README.md)
[![CI](https://github.com/sky-distribution/policy-service/actions/workflows/main.yml/badge.svg)](https://github.com/sky-distribution/policy-service/actions/workflows/main.yml) [![digital beesafe cicd](https://github.com/sky-distribution/policy-service/actions/workflows/digital-cicd.yml/badge.svg)](https://github.com/sky-distribution/policy-service/actions/workflows/digital-cicd.yml)

# Policy Service

Welcome to policy service, a central hub for everything relating policies and submissions in Beesafe.

# Running

## Running the project the simple way
First you need to set your github access token to NPM_TOKEN (see .env.example).
Windows:
```
set NPM_TOKEN=<your token>
```

Ubuntu:
```
export NPM_TOKEN=<your token>
```

To simply run the project and start hacking away, just run
```
docker-compose up --build
```

This will build the project and start it together with an instance of Postgres Database and a RabbitMQ service.

Changing the files in the project will reload the server, too.

## Advanced

To start the project separately, you need to set up your .env file based on .env.example file.
You need a postgres and a rabbitmq service running to be able to start the project.

To start the built version, you fist need to build it:
```
npm run build
```

and then
```
npm start
```

To start the live version, use:
```
npm run start:dev
```

### Testing the message queue
To test if the messages work, you can enter the rabbit UI and search for the required queue
http://localhost:15672/#/queues/%2F/policy-service

Default user-password:
guest
guest

Here, you can send a message with the body:
```
{
  "cmd": "policyService.test.testMessage",
  "content": ""
}
```

## Testing
Tests cover the controllers, to run them use:
```
npm test
```
