You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Our current sysndd_plumber.R script has grown large and unwieldy, mixing endpoint definitions for entities, reviews, re-reviews, publications, and more into a single file. This issue proposes refactoring the code to maintain each logical group of endpoints in its own file under a dedicated endpoints/ folder. The goal is better readability, maintainability, and testability of the API codebase.
Why This Matters
Maintainability: Smaller, domain-focused endpoint files make it easier to locate relevant code.
Collaboration: Team members can edit endpoint files without merging conflicts in the monolith.
Testability: Each endpoint set can be more easily unit tested, loaded, or debugged independently.
Clarity: Reduces confusion by separating business logic from the overarching API router code.
Proposed Implementation Plan
Create endpoints/ Folder
Under api/, create a new endpoints folder (i.e., api/endpoints/).
Identify Endpoint Sections in sysndd_plumber.R
Look for the major headings in the file, e.g.
## Entity endpoints
## Review endpoints
## Re-review endpoints
## Publication endpoints
... and so forth.
Extract Endpoint Blocks into New Files
For each heading, create a corresponding file in endpoints/. Example:
api/endpoints/entity_endpoints.R
api/endpoints/review_endpoints.R
api/endpoints/re_review_endpoints.R
and so on.
Copy the relevant endpoints (the #* @get, #* @post definitions and their corresponding code) into the new file.
Remove the original code from sysndd_plumber.R once it’s in the new file.
Source Endpoint Files in sysndd_plumber.R
In the now-simplified sysndd_plumber.R, after loading libraries and config, source() each of the new endpoint files, e.g.:
Keep an eye out for duplicated code or references that might have existed in the monolith.
Ensure environment variables and config remain available to each endpoint file (they are typically loaded once in sysndd_plumber.R, so no changes should be needed).
The text was updated successfully, but these errors were encountered:
…es (#109)
## Summary
Extracted each logical group of endpoints (entity, review, re-review, etc.) from the monolithic `sysndd_plumber.R` into separate files under `api/endpoints/`. Simplifies code structure, enhances readability, and eases maintenance.
## Details
- Created `api/endpoints/` folder and moved each endpoint block into its own file (e.g., `entity_endpoints.R`, `review_endpoints.R`).
- Removed the corresponding blocks from `sysndd_plumber.R`.
- Updated the main script to `source()` these smaller endpoint scripts.
- Preserved shared logic in `functions/` folder.
- Maintained hooks, filters, authentication, and logging in the main script, ensuring each newly sourced endpoint file inherits them.
Closes#109
Summary
Our current
sysndd_plumber.R
script has grown large and unwieldy, mixing endpoint definitions for entities, reviews, re-reviews, publications, and more into a single file. This issue proposes refactoring the code to maintain each logical group of endpoints in its own file under a dedicatedendpoints/
folder. The goal is better readability, maintainability, and testability of the API codebase.Why This Matters
Proposed Implementation Plan
Create
endpoints/
Folderapi/
, create a newendpoints
folder (i.e.,api/endpoints/
).Identify Endpoint Sections in
sysndd_plumber.R
## Entity endpoints
## Review endpoints
## Re-review endpoints
## Publication endpoints
Extract Endpoint Blocks into New Files
endpoints/
. Example:api/endpoints/entity_endpoints.R
api/endpoints/review_endpoints.R
api/endpoints/re_review_endpoints.R
#* @get
,#* @post
definitions and their corresponding code) into the new file.sysndd_plumber.R
once it’s in the new file.Source Endpoint Files in
sysndd_plumber.R
sysndd_plumber.R
, after loading libraries and config,source()
each of the new endpoint files, e.g.:#* @plumber
function or any required hooks/filters insysndd_plumber.R
.Ensure Helpers Remain in
functions/
api/functions/*.R
.functions/
.Validate and Test
start_sysndd_api.R
) ordocker-compose
as normal.CORS
filter) still work.Commit Messages / Branching
refactor: split sysndd_plumber.R into endpoint-based files
chore: move entity endpoints to entity_endpoints.R
refactor: finalize endpoint folder structure
.Tasks Checklist
endpoints/
directory inapi/
.sysndd_plumber.R
into its own file underendpoints/
.sysndd_plumber.R
.sysndd_plumber.R
,source()
the newendpoints/*.R
files in a logical order.sysndd_plumber.R
apply to the newly sourced endpoints.refactor:
orchore:
following Conventional Commits style.References
Additional Notes
sysndd_plumber.R
, so no changes should be needed).The text was updated successfully, but these errors were encountered: