Aller au contenu

@univ-lehavre/atlas-crf

@univ-lehavre/atlas-crf

Microservice HTTP CRF pour exposer une API REST au-dessus de REDCap.

About

Ce service Hono encapsule le client REDCap Atlas et expose des routes, métadonnées projet, instruments, champs, records, PDF, liens de survey et recherche utilisateur par email. Il ajoute validation Effect, réponses d’erreur normalisées, rate limiting et documentation OpenAPI/Scalar côté serveur.

Features

  • Health checks: état du serveur REDCap, token et latence moyenne
  • Projet REDCap: version, informations projet, instruments, champs et noms d’export
  • Records: export, import, PDF et liens survey avec validation de requête
  • Utilisateurs: résolution d’un utilisateur REDCap par email

Usage

Server

Depuis le monorepo:

Fenêtre de terminal
# Required environment variables
export REDCAP_API_URL=https://redcap.example.com/api/
export REDCAP_API_TOKEN=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
export CRF_AUTH_TOKEN=change-me-shared-bearer-secret
export PORT=3000
# Start the server
pnpm -F @univ-lehavre/atlas-crf start

Les routes /api/* exigent un en-tête Authorization: Bearer $CRF_AUTH_TOKEN (secret partagé statique, requis — le serveur refuse de démarrer sans). Les sondes /health, /openapi.json et /docs restent ouvertes. Voir l’ADR 0041 pour la stratégie d’authentification.

Le package exporte aussi createApp() pour construire l’application Hono dans des tests ou dans un runtime serveur personnalisé.

Server API

EndpointDescription
GET /healthHealth check
GET /api/v1/project/versionREDCap version
GET /api/v1/project/infoProject information
GET /api/v1/project/instrumentsREDCap instruments
GET /api/v1/project/fieldsREDCap data dictionary fields
GET /api/v1/project/export-field-namesExport field name mappings
GET /api/v1/recordsExport records
POST /api/v1/recordsImport records
GET /api/v1/records/:recordId/pdfDownload record PDF
GET /api/v1/records/:recordId/survey-linkGet survey link
GET /api/v1/users/by-email?email=...Find a user
GET /openapi.jsonOpenAPI specification
GET /docsScalar documentation

Scripts

Fenêtre de terminal
pnpm -F @univ-lehavre/atlas-crf start:dev # Development server
pnpm -F @univ-lehavre/atlas-crf build # Production build
pnpm -F @univ-lehavre/atlas-crf test # Unit tests
pnpm -F @univ-lehavre/atlas-crf start # Start built server
pnpm -F @univ-lehavre/atlas-crf test:api # API tests
pnpm -F @univ-lehavre/atlas-crf test:integration # Integration tests

Documentation

Organization

This package is part of Atlas, a set of tools developed by Le Havre Normandie University to facilitate research and collaboration between researchers.

Atlas is developed as part of two projects led by Le Havre Normandie University:


Le Havre Normandie University     Campus Polytechnique des Territoires Maritimes et Portuaires     EUNICoast

License

MIT