tethys.backend/start/routes/api.ts
Arno Kaimbacher c049b22723 - feat: Enhance README with setup instructions, usage, and command documentation
- fix: Update API routes to include DOI URL handling and improve route organization

- chore: Add ORCID preload rule file and ensure proper registration

- docs: Add MIT License to the project for open-source compliance

- feat: Implement command to detect and fix missing dataset cross-references

- feat: Create command for updating DataCite DOI records with detailed logging and error handling

- docs: Add comprehensive documentation for dataset indexing command

- docs: Create detailed documentation for DataCite update command with usage examples and error handling
2025-09-19 14:35:23 +02:00

51 lines
2.6 KiB
TypeScript

import router from '@adonisjs/core/services/router';
import AuthorsController from '#controllers/Http/Api/AuthorsController';
import DatasetController from '#controllers/Http/Api/DatasetController';
import HomeController from '#controllers/Http/Api/HomeController';
import FileController from '#controllers/Http/Api/FileController';
import AvatarController from '#controllers/Http/Api/AvatarController';
import UserController from '#controllers/Http/Api/UserController';
import CollectionsController from '#controllers/Http/Api/collections_controller';
import { middleware } from '../kernel.js';
// Clean DOI URL routes (no /api prefix)
// API routes with /api prefix
router
.group(() => {
router.get('clients', [UserController, 'getSubmitters']).as('client.index').use(middleware.auth());
router.get('authors', [AuthorsController, 'index']).as('author.index').use(middleware.auth());
router.get('datasets', [DatasetController, 'index']).as('dataset.index');
router.get('persons', [AuthorsController, 'persons']).as('author.persons');
// This should come BEFORE any other routes that might conflict
router
.get('/dataset/:prefix/:value', [DatasetController, 'findByIdentifier'])
.where('prefix', /^10\.\d+$/) // Match DOI prefix pattern (10.xxxx)
.where('value', /^[a-zA-Z0-9._-]+\.[0-9]+(?:\.[0-9]+)*$/) // Match DOI suffix pattern
.as('dataset.findByIdentifier');
router.get('/dataset', [DatasetController, 'findAll']).as('dataset.findAll');
router.get('/dataset/:publish_id', [DatasetController, 'findOne']).as('dataset.findOne');
router.get('/sitelinks/:year', [HomeController, 'findDocumentsPerYear']);
router.get('/years', [HomeController, 'findYears']);
router.get('/statistic', [HomeController, 'findPublicationsPerMonth']);
router.get('/file/download/:id', [FileController, 'findOne']).as('file.findOne');
router.get('/avatar/:name/:background?/:textColor?/:size?', [AvatarController, 'generateAvatar']);
router
.post('/twofactor_totp/settings/enable/:state/:code?', [UserController, 'enable'])
.as('apps.twofactor_totp.enable')
.use(middleware.auth());
router
.post('/twofactor_backupcodes/settings/create', [UserController, 'createCodes'])
.as('apps.twofactor_backupcodes.create')
.use(middleware.auth());
router.get('collections/:id', [CollectionsController, 'show']).as('collection.show');
})
// .namespace('App/Controllers/Http/Api')
.prefix('api');