• Elixir 97.5%
  • Shell 1.5%
  • Go Template 0.8%
  • Dockerfile 0.2%
Find a file
semantic-release-bot f08d0dbca0 chore(release): 6.3.2
## [6.3.2](https://gitlab.com/logius/nldoc/web/nldoc_api/compare/6.3.1...6.3.2) (2025-12-26)

### Bug Fixes

* **deps:** update dependency nldoc_s3 to v1.0.9 ([63e9e25](63e9e25dfc))
2025-12-26 11:48:52 +00:00
.ci/semantic-release chore: update references (GitLab migration) 2025-04-03 14:54:20 +02:00
config fix: default name for results stream 2025-12-23 16:24:39 +01:00
helm chore(release): 6.3.2 2025-12-26 11:48:52 +00:00
lib/nldoc feat(deps): upgrade nldoc_conversion_reader_tiptap to v2 2025-12-22 18:47:27 +01:00
test chore(release): 6.3.2 2025-12-26 11:48:52 +00:00
.credo.exs chore: initial commit 2025-01-27 18:03:36 +01:00
.dialyzer_ignore.exs feat!: new conversion endpoints 2025-05-04 17:59:04 +02:00
.dockerignore ci: helm and Dockerfile 2025-01-28 02:50:08 +01:00
.editorconfig chore: set .editorconfig 2025-04-22 01:06:43 +00:00
.formatter.exs feat!: new conversion endpoints 2025-05-04 17:59:04 +02:00
.gitignore feat(NLD-359): Event filtering and passing identifier/event name data 2025-02-24 11:59:47 +01:00
.gitlab-ci.yml chore: update references (GitLab migration) 2025-04-03 14:54:20 +02:00
CHANGELOG.md chore(release): 6.3.2 2025-12-26 11:48:52 +00:00
CODEOWNERS chore: set CODEOWNERS 2025-04-22 00:25:53 +00:00
coveralls.json fix: do not log http closing 2025-12-02 11:05:45 +01:00
docker-compose.yml feat: respond with Trace ID if there is none in request 2025-10-21 01:00:51 +02:00
Dockerfile fix: Dockerfile (apk cli change) 2025-12-22 17:18:34 +01:00
LICENSE chore: initial commit 2025-01-27 18:03:36 +01:00
mix.exs chore(release): 6.3.2 2025-12-26 11:48:52 +00:00
mix.lock fix(deps): update dependency nldoc_s3 to v1.0.9 2025-12-26 11:35:16 +00:00
publiccode.yml chore: add publiccode.yml 2025-06-17 10:51:09 +02:00
README.md docs: env vars 2025-12-22 17:29:45 +01:00
renovate.json chore: update dev deps 2025-05-12 13:57:44 +00:00

NLdoc.API

NLdoc.API is an Elixir-based HTTP API that orchestrates document conversion and validation in the NLdoc ecosystem developed by Logius. It provides REST endpoints for submitting documents for conversion, streaming conversion events, downloading results, and performing direct validation.

API Endpoints

Endpoint Method Description Content Type
/conversion POST Submit document(s) for conversion Multipart or binary upload
/conversion/:id GET Stream conversion events (SSE) text/event-stream
/file/:key GET Download converted file Original file content type
/validation POST Validate document directly application/vnd.nldoc.spec+json or .tiptap+json
/health GET Health check endpoint application/json

Conversion Workflow

  1. Upload: POST /conversion with file(s), optionally specify x-target-content-type
  2. Response: Receive job UUID(s) and conversion details
  3. Monitor: GET /conversion/:id to stream events (started, progress, completed, failed)
  4. Download: GET /file/:key to retrieve converted document

Requirements

  • Elixir 1.19+ / OTP 28+
  • RabbitMQ (AMQP)
  • S3-compatible storage (AWS S3 or MinIO)
  • NLdoc Worker instances for processing conversions

Installation

Docker

$ docker build -t nldoc-api .
$ docker run -e AMQP_HOST=rabbitmq -e S3_HOST=minio nldoc-api

Helm

$ helm install nldoc-api nldoc/nldoc-api -f values.yaml

Configuration

Environment variables

# URL to the JSON Web Key Set (JWKS) for JWT token validation. If not set, authentication is disabled.
AUTH_JWKS_URL=""

# Port number for the HTTP server to listen on.
PORT="4000"

# Path to CA certificates file for SSL/TLS verification when connecting to S3. If set, enables peer verification for S3 connections.
CA_CERTIFICATES_PATH=""

# Protocol scheme for S3 connections (http or https).
S3_SCHEME="http"

# Hostname of the S3-compatible storage service.
S3_HOST="localhost"

# Port number of the S3-compatible storage service.
S3_PORT="9000"

# Access key ID for S3 authentication.
S3_ACCESS_KEY="minio"

# Secret access key for S3 authentication.
S3_SECRET_KEY="1234567890"

# AWS region for S3 service.
S3_REGION="eu-west-1"

# S3 bucket name for file uploads. Falls back to `S3_BUCKET_NAME_FILES` if not set.
S3_BUCKET_UPLOADS="files"

# Alternative environment variable for S3 uploads bucket name (fallback for `S3_BUCKET_UPLOADS`).
S3_BUCKET_NAME_FILES="files"

# S3 bucket name for file downloads/output. Falls back to `S3_BUCKET_NAME_OUTPUT` if not set.
S3_BUCKET_DOWNLOADS="output"

# Alternative environment variable for S3 downloads bucket name (fallback for `S3_BUCKET_DOWNLOADS`).
S3_BUCKET_NAME_OUTPUT="output"

# Hostname of the AMQP/RabbitMQ message broker.
AMQP_HOST="localhost"

# Port number of the AMQP/RabbitMQ message broker.
AMQP_PORT="5672"

# Username for AMQP authentication.
AMQP_USERNAME="amqp"

# Password for AMQP authentication.
AMQP_PASSWORD="amqp"

# AMQP queue name for event messages.
AMQP_QUEUE_EVENT="events"

Usage

Development

$ mix deps.get
$ mix compile
$ mix run --no-halt

Production

$ MIX_ENV=prod mix release
$ _build/prod/rel/nldoc_api/bin/nldoc_api start

Development

Testing

# Run all tests
$ mix test

# Test coverage
$ MIX_ENV=test mix coveralls.json
$ MIX_ENV=test mix coveralls.html

# Coverage reports
$ mix coveralls.cobertura

Code Quality

# Format code
$ mix format

# Static analysis
$ mix credo

# Type checking
$ mix dialyzer

# Dependency audit
$ mix deps.audit

Logging

Structured JSON logging with ECS-compliant format:

  • Application version and environment
  • Service metadata (name, version, environment)
  • Correlation and trace IDs (trace.id, http.request.id)
  • Request/response logging via LoggerJSON.Plug

Example:

{
  "message": "Starting NLdoc API server v6.1.1 (env: prod, port: 4000)",
  "service.name": "nldoc_api",
  "service.version": "6.1.1",
  "service.environment": "prod",
  "@timestamp": "2025-12-22T13:36:19.998Z",
  "log.level": "info",
  "ecs.version": "8.11.0"
}

License

EUPL-1.2 (European Union Public License 1.2)