Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
293 commits
Select commit Hold shift + click to select a range
ee38a05
188 epic middleware to upgrade imported manifests (#218)
cubap Apr 4, 2025
a05f665
hulk smash 👊🏽
cubap Apr 4, 2025
3f69eae
_sub is no longer missing on invitees
cubap Apr 7, 2025
5463482
add temp sub to new user
cubap Apr 7, 2025
4271df8
Update cd_dev.yaml
cubap Apr 7, 2025
24c38aa
Update cd_dev.yaml
cubap Apr 7, 2025
923196a
stop if things are missing
cubap Apr 7, 2025
7d97630
adding verify on main
cubap Apr 7, 2025
c2922a4
Removing fileSystem from Github API (#214)
mepripri Apr 10, 2025
94af054
220 services for bug reporting and feedback (#221)
cubap Apr 10, 2025
c5822ee
cicd (#222)
cubap Apr 10, 2025
73112d3
220 services for bug reporting and feedback (#224)
cubap Apr 14, 2025
5ce579a
API call to Update Profile (#223)
mepripri Apr 16, 2025
b87b731
Save AnnotationCollection, Pages and Annotations to RERUM (#215)
mepripri Apr 23, 2025
e9971bc
Update index.mjs
mepripri Apr 25, 2025
5dd077e
Update index.mjs
mepripri Apr 25, 2025
0906084
Update index.mjs
mepripri Apr 25, 2025
6bf9c9a
Update index.mjs
mepripri Apr 25, 2025
afe664e
Update index.mjs
mepripri Apr 28, 2025
b646fb7
Import TPEN28 (#226)
mepripri Apr 28, 2025
f390c1b
Merge branch 'development' of https://github.com/CenterForDigitalHuma…
cubap Apr 28, 2025
fd23a3e
Test restoration (#229)
cubap Apr 28, 2025
39eb96b
Merge branch 'development' of https://github.com/CenterForDigitalHuma…
cubap Apr 28, 2025
e7704b4
un-mjs
cubap Apr 28, 2025
20ce23c
Refactor all .mjs files to .js and update imports. Closes #194 (#228)
cubap Apr 29, 2025
d1f5eaa
Merge branch 'main' into development
cubap Apr 29, 2025
b5f46f8
Update package-lock.json
cubap Apr 29, 2025
673a5c5
Using UID to get User Projects
mepripri Apr 29, 2025
ac0182f
Update index.mjs
mepripri Apr 30, 2025
9f102fb
Merge branch 'development' of https://github.com/CenterForDigitalHuma…
cubap Apr 30, 2025
6e79a8d
Merge branch 'development' into import-tpen28
mepripri Apr 30, 2025
443d0a2
no label is fine for Pages
cubap Apr 30, 2025
2e5bbbd
Merge branch 'development' of https://github.com/CenterForDigitalHuma…
cubap May 1, 2025
83fac3a
Merge branch 'development' into import-tpen28
mepripri May 1, 2025
d2ec198
Origin Fetch
mepripri May 1, 2025
dde7c30
SetHeader Origin
mepripri May 1, 2025
f977234
Update index.js
mepripri May 1, 2025
280dd45
Update index.js
mepripri May 1, 2025
4ad48ec
Update index.js
mepripri May 1, 2025
52edaab
Getting User Projects (#237)
mepripri May 2, 2025
032ef45
Merge branch 'development' into import-tpen28
cubap May 5, 2025
447490b
Update validateURL.js
mepripri May 6, 2025
de392a1
Merge branch 'development' into import-tpen28
cubap May 7, 2025
44b75cf
Localhost URLS Validating (#242)
mepripri May 7, 2025
4ee227a
231 create overwrite layer (#239)
cubap May 7, 2025
20305c0
remove unused file
thehabes May 12, 2025
66b3b5c
235 save annotations (#240)
cubap May 14, 2025
1f4c5d2
230 clean up project routers (#245)
cubap May 16, 2025
13830ee
Adding Tools to Project (#244)
mepripri May 19, 2025
da4986d
Merge branch 'development' into import-tpen28
mepripri May 19, 2025
0537b1f
Merge branch 'development' into import-tpen28
mepripri May 19, 2025
3c59aea
Merge branch 'import-tpen28' of https://github.com/CenterForDigitalHu…
mepripri May 20, 2025
adf2e4f
Adding endpoint to add multiple lines to a page
mepripri May 20, 2025
8b1aad5
Update index.js
mepripri May 20, 2025
1957b73
Add project metrics to /my/projects (#227)
git-voo May 21, 2025
43a322e
Merge branch 'development' into import-tpen28
mepripri May 21, 2025
5b220f3
Update index.js
mepripri May 21, 2025
93cf7a4
Merge branch 'import-tpen28' of https://github.com/CenterForDigitalHu…
mepripri May 21, 2025
1e6df19
co-op
thehabes May 21, 2025
c6b69d6
co-op
thehabes May 21, 2025
2eba4aa
co-op
thehabes May 21, 2025
b8f1e24
OK log time
thehabes May 21, 2025
ccd2ad8
do 401 from TPEN2 the right way
thehabes May 21, 2025
1e103b6
do 401 from TPEN2 the right way
thehabes May 21, 2025
b8fa84c
do 401 from TPEN2 the right way
thehabes May 21, 2025
7b735f5
do 401 from TPEN2 the right way
thehabes May 21, 2025
ebdcd13
gotta import the function
thehabes May 21, 2025
272ca58
Update index.js
mepripri May 21, 2025
3a2769f
Merge branch 'import-tpen28' of https://github.com/CenterForDigitalHu…
mepripri May 21, 2025
4e9bcaf
Need to import Project
thehabes May 21, 2025
7e57428
Merge branch 'import-tpen28' of https://github.com/CenterForDigitalHu…
thehabes May 21, 2025
39c110f
Need to import Project
thehabes May 21, 2025
68da79d
Good to go
thehabes May 21, 2025
07db204
Separating files
mepripri May 21, 2025
a5ce55d
Merge pull request #251 from CenterForDigitalHumanities/import-tpen28
mepripri May 21, 2025
629447e
add metarecords to new Projects (#254)
cubap May 28, 2025
9ed3175
256 import creates bad ids (#257)
cubap May 28, 2025
d9a6d76
always trim lastModified
cubap May 29, 2025
0fd815b
hotifx invite code
thehabes May 29, 2025
c4c2512
Email invite, upgrade temp user (#259)
thehabes Jun 11, 2025
0c21de8
hotfix links in E-mail
thehabes Jun 11, 2025
f0d7bc2
hotfix links in E-mail
thehabes Jun 11, 2025
36ed128
Align User With Project After Invite (#263)
thehabes Jun 12, 2025
7d68ee8
Create New Project from One Image
mepripri Jun 16, 2025
0ad0888
Update ProjectFactory.js
mepripri Jun 16, 2025
e52c8cc
Removing services
mepripri Jun 17, 2025
7227a9e
Update ProjectFactory.js
mepripri Jun 18, 2025
b4f104d
Update ProjectFactory.js
mepripri Jun 18, 2025
6e4d54b
MimeTypes
mepripri Jun 18, 2025
b1dd2ba
cleanup
thehabes Jun 18, 2025
d6e4ac7
Merge pull request #265 from CenterForDigitalHumanities/create-new-pr…
mepripri Jun 18, 2025
33fde1e
Decline Project Invite - Service (#264)
thehabes Jun 20, 2025
1a8a684
support text/plain request bodies (#268)
thehabes Jun 23, 2025
b80228c
Implement optimistic locking for page and line updates
cubap Jun 24, 2025
48a60f5
IIIF Image Service (#266)
mepripri Jun 26, 2025
d147cea
270 multiple updates to a page in parallel discards data (#271)
cubap Jul 1, 2025
29d45c3
Copy Project API (#272)
mepripri Jul 9, 2025
ba418c0
Project label update API (#273)
mepripri Jul 9, 2025
3523fa7
Level 0 image fix for TPEN28 imported Projects (#274)
mepripri Jul 10, 2025
1b6f74a
Adding Creator (#275)
mepripri Jul 18, 2025
c98a41c
Layer and Page Management Endpoints (#278)
thehabes Jul 23, 2025
ab82078
Revert "Layer and Page Management Endpoints (#278)" (#283)
thehabes Jul 23, 2025
241b4af
Project Export Message (#277)
mepripri Jul 25, 2025
9445392
Layer and Page Management Endpoints (#284)
thehabes Jul 29, 2025
b3376d1
Update Copy Project Layer Fix (#285)
mepripri Jul 29, 2025
57d6365
Project export message (#286)
mepripri Jul 29, 2025
2d0b203
Page and Layer Label Hotfix (#287)
mepripri Jul 30, 2025
e145229
Pair Coding Hotfixes (#288)
thehabes Jul 30, 2025
6e25780
ugh
thehabes Jul 30, 2025
1bccbcd
ugh
thehabes Jul 30, 2025
546f1c4
ugh
thehabes Jul 30, 2025
4e9617e
ugh
thehabes Jul 30, 2025
9540159
ugh
thehabes Jul 30, 2025
6577fb6
ugh
thehabes Jul 30, 2025
470bf0b
ugh
thehabes Jul 30, 2025
7bde502
ugh
thehabes Jul 30, 2025
0e0edd1
remove logs from testing ugh
thehabes Jul 30, 2025
5d0c879
Project Tools Fix (#290)
mepripri Aug 1, 2025
b945e88
ah forgot to commit touchups
thehabes Aug 1, 2025
fedf0e2
Leave Project Endpoint (#289)
thehabes Aug 5, 2025
4e72e12
Creator on text and bounds (#294)
cubap Aug 7, 2025
a6c28ca
276 upgrade temp ids referenced in rerum data (#296)
cubap Aug 11, 2025
85889cf
Set line creator if not already defined (#305)
cubap Aug 19, 2025
875b98d
Project Update Roles (#291)
mepripri Aug 20, 2025
70b2207
Project roles fix (#306)
mepripri Aug 20, 2025
d4aec32
TPEN28 Fix (#300)
mepripri Aug 20, 2025
73988d2
295 contentchanged for layers and pages (#298)
cubap Aug 21, 2025
55f7cab
TPEN28 Multiple Users Fix (#307)
mepripri Sep 2, 2025
58bff9a
public-profile (#299)
mepripri Sep 2, 2025
e8ed4a8
Fix up error responses, and expectations for those responses in the t…
thehabes Sep 2, 2025
ea31512
/:lineid/text hotfix (#310)
thehabes Sep 4, 2025
836e9df
Tpen28 Cookies Change (#311)
mepripri Sep 9, 2025
e3ffcdd
Protect PATCH /:projectId/label Endpoint (#308)
thehabes Sep 11, 2025
4737e22
Merge branch 'development' of https://github.com/CenterForDigitalHuma…
cubap Sep 12, 2025
bdd8420
Add protection to /project/metadata route (#316)
thehabes Sep 12, 2025
6785e41
Protect POST /project/create with screenContentMiddleware to block su…
thehabes Sep 15, 2025
5f7fcdd
Merge branch 'main' into development
cubap Sep 15, 2025
3bc5bd0
Merge branch 'development' of https://github.com/CenterForDigitalHuma…
cubap Sep 15, 2025
b9ac9bf
Protect /project/addRoles and /project/setRoles routes (#322)
thehabes Sep 16, 2025
9f8d1f0
Add comprehensive CONTRIBUTING.md guide for Node.js, Git, and local d…
Copilot Sep 17, 2025
f451eb7
Revise CONTRIBUTING.md for clarity and updates
cubap Sep 17, 2025
2759f58
Protect /project/create Route (#320)
thehabes Sep 17, 2025
c50d357
Merge branch 'development' of https://github.com/CenterForDigitalHuma…
cubap Sep 19, 2025
8858fdf
Merge branch 'main' into development
cubap Sep 19, 2025
406b034
Remove unused optimistic locking utilities
cubap Sep 19, 2025
759867f
Update utilities/shared.js
cubap Sep 19, 2025
8d8ed01
Update utilities/checkIfSuspicious.js
cubap Sep 19, 2025
7e73531
Protect PUT /profile route (#331)
thehabes Sep 19, 2025
f48a8a1
Default Tools and New Project with custom Tools (#328)
mepripri Sep 19, 2025
f1ba631
Changes to Tools endpoint (#346)
mepripri Sep 23, 2025
15384c2
Protect /project/import and /project/import-image routes (#326)
thehabes Sep 23, 2025
5f0bdb4
suspicious test fix
thehabes Sep 23, 2025
163aace
Enhance /project/create request body validation to prevent malformed …
Copilot Sep 23, 2025
5594bb3
newLineIndex === -1 logic
thehabes Sep 23, 2025
9461e84
logical errors
thehabes Sep 23, 2025
b1daad0
Add suspicious content protection to POST /layer route (#350)
Copilot Sep 29, 2025
0b4b18b
Add suspicious content protection to PUT /layer/:layerId route (#351)
Copilot Sep 29, 2025
dc44bf4
tagName fix for Tools (#349)
mepripri Sep 30, 2025
2a7d1a0
Protect PUT /page/:pageid Route (#352)
thehabes Oct 1, 2025
3461008
Add suspicious content protection to POST /line/ route (#353)
Copilot Oct 1, 2025
423769b
Protect PUT /line/:lineid Route (#354)
thehabes Oct 1, 2025
c3c6c11
This one is too easy to let AI do (#356)
thehabes Oct 1, 2025
35dcea1
Add suspicious input validation to feedback and bug report routes (#358)
Copilot Oct 1, 2025
38ad147
Node 22.20.0 now
thehabes Oct 1, 2025
d89112b
Page Viewer URL Change (#357)
mepripri Oct 2, 2025
8acffa9
Metadata Fix (#360)
mepripri Oct 2, 2025
91cfbfb
hotfix test
thehabes Oct 2, 2025
70514cb
metadata hotfix (#361)
mepripri Oct 2, 2025
873bf48
Remove /manifest directory and unregister manifest routes (#363)
thehabes Oct 2, 2025
24aec94
Add web-friendly API documentation for TPEN services (#301)
Copilot Oct 3, 2025
c333b5f
NPM Package Updates for package.json (#359)
thehabes Oct 3, 2025
b1ba2a9
Update API.html styles for improved readability
cubap Oct 3, 2025
f2b52a4
fix line getter
thehabes Oct 3, 2025
84783f1
fix line getter
thehabes Oct 3, 2025
f9344d1
fix line getter
thehabes Oct 3, 2025
b6f4173
Update project/projectToolsRouter.js
thehabes Oct 3, 2025
d7ed12b
TPEN28 Tools Fix (#365)
mepripri Oct 6, 2025
1388354
Preview Transcription Default Tool (#368)
mepripri Oct 8, 2025
81c3484
Add Tests to Check If Routes Exist (#367)
thehabes Oct 8, 2025
43db3a3
Line Break URL (#371)
mepripri Oct 10, 2025
a0ea62e
369 support namespaced project metadata (#370)
cubap Oct 15, 2025
4e0b682
Location Fix (#372)
mepripri Oct 20, 2025
8f64829
Create Project with Multiple Images (#373)
mepripri Nov 3, 2025
38df33b
claude on development
thehabes Nov 10, 2025
36be993
Add Claude Code GitHub Actions workflow
thehabes Nov 10, 2025
8b7e5ba
Go prd (#374)
cubap Nov 10, 2025
e60d2dc
Merge branch 'main' into development
cubap Nov 10, 2025
3071a96
deduped
cubap Nov 10, 2025
e4e480b
how we feeling?
cubap Nov 10, 2025
5e88be0
Links into RERUM APIs and code and the TPEN3 home page.
thehabes Nov 10, 2025
4fc3339
Fix PM2 cluster mode environment variable loading (#379)
thehabes Nov 11, 2025
6ca1faa
ftw
thehabes Nov 11, 2025
a2d2940
The file
thehabes Nov 11, 2025
6ad60f1
cmon
thehabes Nov 11, 2025
2bd6757
redo with human
thehabes Nov 11, 2025
ca5f25c
cleanup
thehabes Nov 11, 2025
0370469
cleanup
thehabes Nov 11, 2025
5662474
Let's see how RHEL feels about this (#380)
thehabes Nov 11, 2025
6f86b7f
ah I see probably still need dotenv here in the app.js
thehabes Nov 11, 2025
f50439b
get them .env vars back cmon
thehabes Nov 11, 2025
fc37141
trying
thehabes Nov 11, 2025
37c8654
Ok then let's have you do it like before
thehabes Nov 11, 2025
c6324a0
Debug logs
thehabes Nov 11, 2025
e557882
Verified I can get it to work the old way, so take steps towards the …
thehabes Nov 11, 2025
b7b3b2d
closer, logs are being weird though.
thehabes Nov 11, 2025
9cd1bd1
paths maybe?
thehabes Nov 11, 2025
ae0e2da
stick a fork in it
thehabes Nov 11, 2025
c559c37
stick a fork in it
thehabes Nov 11, 2025
9767730
stick a fork in it
thehabes Nov 11, 2025
59e62a0
I think it works!
thehabes Nov 11, 2025
b160c8d
Closer
thehabes Nov 11, 2025
cdfdc18
stop smoking
thehabes Nov 11, 2025
8563249
yaml supports if tpen3_services isn't already registered in pm2
thehabes Nov 11, 2025
da30f02
Update env-loader.js
thehabes Nov 11, 2025
c9d2e1a
Update __tests__/mount.test.js
thehabes Nov 11, 2025
a559eb7
Update Group.js
cubap Nov 12, 2025
d0f1d02
Merge branch 'development' of https://github.com/CenterForDigitalHuma…
cubap Nov 12, 2025
2bd64a0
Cleanup (#381)
thehabes Nov 12, 2025
829c439
Merge branch 'main' into development
thehabes Nov 12, 2025
81c5ee9
Merge branch 'main' into development
thehabes Nov 12, 2025
699881c
Signup - Login - Logout - Invite - Reject (#412)
thehabes Nov 25, 2025
57f3194
/page/:pageid/resolved Endpoint (#397)
thehabes Nov 25, 2025
42becae
Remove introduced this.update() calls in Group.js
thehabes Nov 25, 2025
3b0fc91
Invite and Reject Flows (#417)
thehabes Nov 26, 2025
ea44f0a
Only Update Lines (Annotations) That Have Changed (#419)
thehabes Nov 26, 2025
10a1970
dang this needs to go to development as a hotfix (#420)
thehabes Nov 26, 2025
81fb9b5
Let Members Leave Projects (#421)
thehabes Dec 1, 2025
f96b930
Create a New Column (#396)
mepripri Dec 2, 2025
e955f60
hotfix test
thehabes Dec 2, 2025
9f5c4f3
Page update for columns (#424)
mepripri Dec 10, 2025
62fd563
Return 200 with empty array for /my/projects when user has no project…
Copilot Dec 10, 2025
2dae7bf
PATCH /text Runtime Improvements (#429)
thehabes Dec 10, 2025
be2c765
Error Catching and Logging In Routes (#423)
thehabes Dec 10, 2025
a403889
hotifx merge stuff
thehabes Dec 10, 2025
4139492
hotfix for column passing
thehabes Dec 10, 2025
2778414
'pixel' in fragment selector hotfix (#433)
thehabes Dec 12, 2025
7445f91
TPEN Services npm Package Updates (#438)
thehabes Dec 18, 2025
cec7a0a
Authentication (token 400 or 401) and Authorization (user permissions…
thehabes Jan 9, 2026
c2f669e
Align Packages (#444)
thehabes Jan 9, 2026
ae3aea9
Personalized Name String in E-mails (#449)
thehabes Feb 18, 2026
2b0c24a
Validate PATCH /line/:lineid/bounds requests (#452)
thehabes Feb 23, 2026
1b40639
407 update updates (#454)
cubap Feb 24, 2026
381eb37
New GET /line/:lineid?text=blob Feature (#455)
thehabes Feb 26, 2026
06d4d45
407 do over (#458)
cubap Feb 26, 2026
2c7813f
Page Routes With Page and Line Class Refactor (#461)
thehabes Mar 5, 2026
a07b0d4
Layer Routes With Layer, Page, and Line Class Refactor (#469)
thehabes Mar 10, 2026
86bb137
NPM Package Updates (#472)
thehabes Mar 12, 2026
3e04771
Replace Bad Instance of `databaseTiny.find()` (#474)
thehabes Mar 12, 2026
9240ab3
Remove API.md and jsdom/dompurify/marked dependencies (#477)
Copilot Mar 16, 2026
8e5e4ba
Eliminate redundant project DB fetches across route handlers (#478)
Copilot Mar 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
185 changes: 9 additions & 176 deletions .claude/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,202 +6,35 @@ This file provides guidance to AI Assistants when working with code in this repo

TPEN Services is a Node.js Express API service for TPEN3 (Transcription for Paleographical and Editorial Notation). This provides RESTful APIs for digital humanities, cultural heritage, annotation services, and IIIF manifest handling. The service supports multiple database backends (MongoDB, MariaDB) and uses Auth0 for authentication.

Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.

## Working Effectively

### Bootstrap, Build, and Test the Repository
- Copy environment configuration: `cp .env.development .env`
- Environment configuration is in .env. Do not overwrite the existing .env file. If an .env file does not exist then copy environment configuration: `cp .env.development .env`
- Install dependencies: `npm install` -- takes up to 20 seconds. NEVER CANCEL. Set timeout to 60+ seconds.
- Run unit tests: `npm run unitTests` -- takes 12 seconds. NEVER CANCEL. Set timeout to 30+ seconds.
- Run existence tests: `npm run existsTests` -- takes 7 seconds. NEVER CANCEL. Set timeout to 30+ seconds.
- Run all tests: `npm run allTests` -- takes 12 seconds. NEVER CANCEL. Set timeout to 30+ seconds.

### Run the Application
- ALWAYS run the bootstrapping steps first.
- Production server: `npm start` -- starts on port 3011
- Development server: `npm run dev` -- starts with nodemon auto-reload on port 3011
- Test basic functionality: `curl http://localhost:3011/` should return "TPEN3 SERVICES BABY!!!"

### Environment Requirements
- Node.js >= 22.20.0
- MongoDB (for database tests and full functionality)
- MariaDB (for database tests and full functionality)
- Copy `.env.development` to `.env` for basic functionality
- For full functionality, configure database connection strings in `.env`
- Test basic functionality: `curl http://localhost:3011/API.html` should return the API page.

## Validation

### Always Validate Core Functionality After Changes
- Start the application: `npm start` or `npm run dev`
- Test the root endpoint: `curl http://localhost:3011/` -- should return HTML with "TPEN3 SERVICES BABY!!!"
- Run unit tests that don't require databases: `npm run unitTests` -- many tests pass without database connections
- Run existence tests: `npm run existsTests` -- validates route registration and class imports
- ALWAYS wait for full test completion. Tests may appear to hang but will complete within 12 seconds.
- NOTE: Application may crash after serving initial requests due to database connection attempts - this is expected behavior without running MongoDB/MariaDB.

### Test Categories Available
- `npm run unitTests` -- Core unit tests (some require databases)
- `npm run existsTests` -- Route and class existence validation (database-independent)
- `npm run functionsTests` -- Function-level tests
- `npm run E2Etests` -- End-to-end API tests
- `npm run dbTests` -- Database-specific tests (require running databases)
- `npm run authTest` -- Authentication tests (require Auth0 configuration)
- Run `npm run allTests` once you have completed your task and need to verify correctness before continuing.
- ALWAYS wait for full test completion. Tests can take minutes. NEVER CANCEL.
- NOTE: Application may crash after serving initial requests due to database connection attempts - this is expected behavior without a connection to MongoDB.

### Expected Test Behavior
- Tests requiring databases will timeout/fail without MongoDB/MariaDB running
- Auth tests fail without proper AUDIENCE and DOMAIN environment variables
- Core functionality tests (exists, basic units) should pass with minimal `.env` setup
- Database-independent tests complete in 6-15 seconds

## Common Tasks

### Repository Structure
```
/home/runner/work/TPEN-services/TPEN-services/
├── app.js # Express application setup
├── bin/tpen3_services.js # Server entry point
├── package.json # Dependencies and scripts
├── jest.config.js # Test configuration
├── config.env # Safe defaults (committed)
├── .env.development # Development template
├── .env.production # Production template
├── API.md # API documentation
├── classes/ # Domain model classes
│ ├── Project/ # Project management
│ ├── User/ # User management
│ ├── Group/ # Group management
│ ├── Layer/ # Annotation layers
│ ├── Line/ # Text line handling
│ ├── Page/ # Page management
│ └── Manifest/ # IIIF manifest handling
├── database/ # Database drivers
│ ├── mongo/ # MongoDB controller
│ ├── maria/ # MariaDB controller
│ └── tiny/ # TinyPEN API controller
├── auth/ # Auth0 authentication
├── project/ # Project API routes
├── userProfile/ # User API routes
├── line/ # Line API routes
├── page/ # Page API routes
└── utilities/ # Helper functions
```

### Key API Endpoints
- `GET /` -- Service status (returns "TPEN3 SERVICES BABY!!!")
- `GET /project/:id` -- Get project by ID (requires authentication)
- `POST /project/create` -- Create new project (requires authentication)
- `POST /project/import?createFrom=URL` -- Import project from IIIF manifest
- `GET /user/:id` -- Get user profile (public)
- `GET /my/profile` -- Get authenticated user profile
- `GET /line/:id` -- Get text line annotation
- `GET /page/:id` -- Get annotation page

### Authentication
- Uses Auth0 JWT bearer tokens
- Protected endpoints require `Authorization: Bearer <token>` header
- Environment variables AUDIENCE and DOMAIN must be configured for auth tests
- Public endpoints: `/`, `/user/:id`
- Protected endpoints: `/project/*`, `/my/*`, most POST/PUT/DELETE operations

### Database Configuration
- MongoDB: Configure MONGODB and MONGODBNAME in `.env`
- MariaDB: Configure MARIADB, MARIADBNAME, MARIADBUSER, MARIADBPASSWORD in `.env`
- TinyPEN API: Configure TINYPEN in `.env`
- Default configurations in `config.env` point to localhost development services

### Development Workflow
1. Always start with: `cp .env.development .env && npm install`
1. Ensure .env exists (if not: `cp .env.development .env`) and run `npm install`
2. Make code changes
3. Test with: `npm run existsTests` (fast, database-independent)
4. For database changes: ensure MongoDB/MariaDB running, then `npm run dbTests`
5. For API changes: `npm run E2Etests`
6. Start dev server: `npm run dev`
7. Test manually: `curl http://localhost:3011/` and relevant endpoints

### Debugging and Troubleshooting
- Application logs appear in console when running `npm start` or `npm run dev`
- Database connection errors indicate missing database services
- Auth errors indicate missing AUDIENCE/DOMAIN environment variables
- 404 errors on routes indicate route registration issues
- Check `app.js` for middleware and route registration
- Jest warnings about experimental VM modules are expected (ES module usage)

### CI/CD Integration
- GitHub Actions workflows in `.github/workflows/`
- `test_pushes.yaml` runs unit tests on pushes
- `ci_dev.yaml` runs E2E tests on PRs to development
- Tests require environment secrets configured in GitHub repository settings

### Performance Notes
- Application startup: 2-3 seconds
- npm install: ~1-20 seconds depending on cache (timeout: 60+ seconds)
- Unit tests: ~12 seconds (timeout: 30+ seconds)
- Existence tests: ~7 seconds (timeout: 30+ seconds)
- Database tests: variable depending on database response times

### Critical Environment Variables
Required for basic functionality:
- `PORT` (default: 3011)
- `SERVERURL` (default: http://localhost:3011)

Required for database functionality:
- `MONGODB` (MongoDB connection string)
- `MONGODBNAME` (MongoDB database name)
- `MARIADB` (MariaDB host)
- `MARIADBNAME`, `MARIADBUSER`, `MARIADBPASSWORD` (MariaDB credentials)

Required for authentication:
- `AUDIENCE` (Auth0 audience)
- `DOMAIN` (Auth0 domain)

Required for external services:
- `TINYPEN` (TinyPEN API base URL)
- `RERUMURL` (RERUM repository URL)

### Manual Testing Scenarios
After making changes, always validate:
1. **Basic Service**: Start server with `npm start`, test with `curl http://localhost:3011/` - should return HTML containing "TPEN3 SERVICES BABY!!!" in the response body
2. **Route Registration**: `npm run existsTests` passes without errors
3. **Core Logic**: `npm run unitTests` passes tests that don't require databases (some MongoDB tests will timeout - this is expected)
4. **API Authentication**: Protected endpoints like `/my/profile` return 401 status code without valid tokens
5. **Application Behavior**: Server may crash after serving requests when MongoDB is not available - this is expected and indicates database connection attempts are working correctly

### Complete Validation Workflow Example
```bash
# Basic setup
cp .env.development .env
npm install

# Test core functionality without databases
npm run existsTests # Should pass completely
npm run unitTests # Should pass most tests, MongoDB tests will timeout

# Test application serving
npm start &
sleep 3
curl http://localhost:3011/ # Should return HTML with service name
curl -w "Status: %{http_code}\n" http://localhost:3011/my/profile # Should return 401
kill %1 # Stop the background server
```

### Common File Locations
- Main application entry: `bin/tpen3_services.js`
- Express app setup: `app.js`
- Route definitions: `project/index.js`, `userProfile/index.js`, etc.
- Database controllers: `database/mongo/controller.js`, `database/maria/controller.js`
- Authentication middleware: `auth/index.js`
- Domain models: `classes/[Entity]/[Entity].js`
- Configuration: `config.env` (safe defaults), `.env.development` and `.env.production` (templates), `.env` (local config, gitignored)

### Dependencies and Versions
- Express.js for REST API framework
- MongoDB driver for document storage
- MariaDB driver for relational storage
- Auth0 libraries for JWT authentication
- Jest for testing framework
- Nodemon for development auto-reload
- IIIF libraries for manifest handling
3. Once the task is complete and verification is needed: `npm run allTests`
4. Start app if manual testing is needed.

### External Resources
- [IIIF Presentation API](https://iiif.io/api/presentation/)
Expand Down Expand Up @@ -231,4 +64,4 @@ kill %1 # Stop the background server
7. Use JDoc style for code documentation. Cleanup, fix, or generate documentation for the code you work on as you encounter it.
8. We use `npm start` often to run the app locally. However, do not make code edits based on this assumption. Production and development load balance in the app with pm2, not by using `npm start`
9. NEVER CANCEL long-running commands. Application builds and tests are designed to complete within documented timeouts. Always wait for completion to ensure accurate validation of changes.
10. All work on issues for bugs, features, and enhancements will target the `development` branch. The `main` branch will only be targetted with hotfixes by admins or by PRs from the `development` branch. New work should branch from `development`.
10. All work on issues for bugs, features, and enhancements will target the `development` branch. The `main` branch will only be targetted with hotfixes by admins or by PRs from the `development` branch. New work should branch from `development`.
18 changes: 0 additions & 18 deletions .claude/settings.json

This file was deleted.

51 changes: 0 additions & 51 deletions .claude/statusline-command.sh

This file was deleted.

Loading
Loading