2WKGHT2TVFMQT7VUL5OCYVNE365QOYNRXA34LOZ4DBFJ2ZVB4XQQC
7ESBJZLIH3TAERLH2HIZAAQHVNVHQWLWCOBLMJRFTIL33YITJNIAC
HM75N4NTZ4BBSSDC7TUSYOQ4SIF3G6KPZA5QRYCVCVRSKQVTJAXAC
YX7LU4WRAUDMWS3DEDXZDSF6DXBHLYDWVSMSRK6KIW3MO6GRXSVQC
M3JUJ2WWZGCVMBITKRM5FUJMHFYL2QRMXJUVRUE4AC2RF74AOL5AC
EUEH65HBT4XZXCNWECJXNDEQAWR2NLNSAXFPXLMQ27NOVMQBJT5QC
ZYT3JRERMYXLMJHLPZYQHAINVMPQLBKGGN7A4C7OTVZDY42ZLTKQC
4M3EBLTLSS2BRCM42ZP7WVD4YMRRLGV2P2XF47IAV5XHHJD52HTQC
POIBWSL3JFHT2KN3STFSJX3INSYKEJTX6KSW3N7BVEKWX2GJ6T7QC
ROQGXQWL2V363K3W7TVVYKIAX4N4IWRERN5BJ7NYJRRVB6OMIJ4QC
// Authentication middleware for protected routes
/**
* Authentication middleware for protected routes
*
* Verifies JWT tokens from the Kinde identity provider using JWKS.
* On successful verification, adds the JWT payload to the context
* for use in route handlers.
*
* @param c - Hono context containing request, response, and environment bindings
* @param next - Next middleware in the chain
* @returns Response with 401 status on auth failure, or passes to next middleware
*/
// Files API route - paginated by cluster ID
/**
* Protected API route to fetch audio files for a specific cluster
*
* Supports pagination and filtering by:
* - Solar night (true/false)
* - Civil night (true/false)
* - Species ID (for files with selections labeled with a specific species)
*
* Returns file data with metadata, moth metadata, and associated species
*/
// Species API route - get species and call types for a dataset
/**
* Protected API route to fetch species and call types for a dataset
*
* Returns a nested structure with species and their associated call types
* Uses a JOIN approach to efficiently fetch related data in a single query
*/
// Selections API route with flexible filtering by dataset and species
/**
* Protected API route to fetch files with selections for a specific dataset and species
*
* Supports pagination and filtering by:
* - Solar night (true/false)
* - Civil night (true/false)
*
* Returns file data with metadata, moth metadata, and associated species
*/