# ows-url-shortener
==================

The Orchard Web Service for Audience Development URL Shortener.

## Getting Started

### Installation

Make sure you have `uv` installed (https://docs.astral.sh/uv/getting-started/installation/).

```bash
curl -LsSf https://astral.sh/uv/install.sh | sh
```

or if `uv` already installed, ensure it is up to date:

```bash
uv self update
```

Prepare environment and install dependencies:

```bash
$ cd ows-url-shortener
$ make env
```

### Running

Copy environment variables:

```bash
cp .env.shadow .env
```

Here is an example of the `.env` file:

```bash
APP_DEBUG=false
Environment=dev
LOG_FORMAT=console

# Auth
JWT_AUTH_ENABLED=true
AUTH_ALLOW_FULL_ACCESS=false

# Kafka
KAFKA_BOOTSTRAP_SERVERS=localhost
KAFKA_USE_SSL=false

SENTRY_DSN=

DATADOG_ENV=

```

Now you can run the FastAPI application on your local instance by running:

```bash
uv run uvicorn url_shortener.api.asgi:app --reload --port=8001
```

or

```bash
make dev
```

Navigate to http://127.0.0.1:8001/docs to view Swagger UI.

---

All make commands will automatically install all dependencies in a virtual environment folder called env.
You can activate a virtual environment by running `source .venv/bin/activate` or using `uv run <command>`.

By using the development server, you will have access to specific features that
are not necessarily available in production, such as the exception tracer.

### Testing

To run the tests, all you have to do is to run:

```bash
(.venv) $ pytest tests/unit/
(.venv) $ pytest tests/integration/
```

or

To run unit tests: `make test`

To run unit tests with coverage reporting: `make test_unit`

To run integration tests: `make test_integration`

### OpenAPI specification

OpenAPI specification available for dev environment only.

Go to http://localhost:8000/docs to view Swagger UI.

To generate `OpenAPI YAML`:

```bash
$ make openapi
```

### Linting

To lint: `make lint`

To format: `make fmt`

### Third-Party Integrations for Reporting

This boilerplate comes with support for Sentry, and Datadog.
