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
* Gave the agent pipeline a try
* Changes while testing and reviewing
* No tests
* Lines section for API.html
* Lines section for API.html
* oo bail on this, it needs to be its own task
* simplify
* Say less in AI assistant files
* Changes while reviewing
* Changes while reviewing
* Remove this section
* clean this up a little
* clean this up a little
* Ah I see this was trying to help how it fails through, but we need these to throw their errors like usual.
* Now it fails through how it is supposed to
* Now it fails through how it is supposed to
* white space lint stuff
* How about a redo for reasons
* clean up function documentation
* changes while reviewing
* touchup for function documentation
* const
* changes during review
* changes during review
* shape of the refactor
* Gotta fix this now then
* Gotta fix this now then
* Remove the fallback conditionals, the Class will handle it
* Remove imported Line function. It is no longer required here
* changes from getting demo to run
* changes from getting demo to run
* Working demo
* Changes during review
* Changes during review
* Gimme those sweet sweet rerum errors
* Gimme those sweet sweet rerum errors
* Changes during review
* changes while testing
* oops bad docs
* Really take the body from RERUM even if falsey
* Changes during standup
* Touchups during final review step
* Touchups during final review step
* Touchups during final review step
Copy file name to clipboardExpand all lines: .claude/CLAUDE.md
+9-183Lines changed: 9 additions & 183 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,209 +6,35 @@ This file provides guidance to AI Assistants when working with code in this repo
6
6
7
7
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.
8
8
9
-
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.
-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`
15
13
- Install dependencies: `npm install` -- takes up to 20 seconds. NEVER CANCEL. Set timeout to 60+ seconds.
16
-
- Run unit tests: `npm run unitTests` -- takes 12 seconds. NEVER CANCEL. Set timeout to 30+ seconds.
17
-
- Run existence tests: `npm run existsTests` -- takes 7 seconds. NEVER CANCEL. Set timeout to 30+ seconds.
18
-
- Run all tests: `npm run allTests` -- takes 12 seconds. NEVER CANCEL. Set timeout to 30+ seconds.
19
14
20
15
### Run the Application
21
16
- ALWAYS run the bootstrapping steps first.
22
17
- Production server: `npm start` -- starts on port 3011
23
18
- Development server: `npm run dev` -- starts with nodemon auto-reload on port 3011
24
-
- Test basic functionality: `curl http://localhost:3011/` should return "TPEN3 SERVICES BABY!!!"
25
-
26
-
### Environment Requirements
27
-
- Node.js >= 22.20.0
28
-
- MongoDB (for database tests and full functionality)
29
-
- MariaDB (for database tests and full functionality)
30
-
- Copy `.env.development` to `.env` for basic functionality
31
-
- For full functionality, configure database connection strings in `.env`
19
+
- Test basic functionality: `curl http://localhost:3011/API.html` should return the API page.
32
20
33
21
## Validation
34
22
35
23
### Always Validate Core Functionality After Changes
36
-
- Start the application: `npm start` or `npm run dev`
37
-
- Test the root endpoint: `curl http://localhost:3011/` -- should return HTML with "TPEN3 SERVICES BABY!!!"
38
-
- Run unit tests that don't require databases: `npm run unitTests` -- many tests pass without database connections
39
-
- Run existence tests: `npm run existsTests` -- validates route registration and class imports
40
-
- ALWAYS wait for full test completion. Tests may appear to hang but will complete within 12 seconds.
41
-
- NOTE: Application may crash after serving initial requests due to database connection attempts - this is expected behavior without running MongoDB/MariaDB.
42
-
43
-
### Test Categories Available
44
-
-`npm run unitTests` -- Core unit tests (some require databases)
45
-
-`npm run existsTests` -- Route and class existence validation (database-independent)
46
-
-`npm run functionsTests` -- Function-level tests
47
-
-`npm run E2Etests` -- End-to-end API tests
48
-
-`npm run dbTests` -- Database-specific tests (require running databases)
49
-
-`npm run authTest` -- Authentication tests (require Auth0 configuration)
24
+
- Run `npm run allTests` once you have completed your task and need to verify correctness before continuing.
25
+
- ALWAYS wait for full test completion. Tests can take minutes. NEVER CANCEL.
26
+
- NOTE: Application may crash after serving initial requests due to database connection attempts - this is expected behavior without a connection to MongoDB.
50
27
51
28
### Expected Test Behavior
52
29
- Tests requiring databases will timeout/fail without MongoDB/MariaDB running
53
30
- Auth tests fail without proper AUDIENCE and DOMAIN environment variables
54
31
- Core functionality tests (exists, basic units) should pass with minimal `.env` setup
55
-
- Database-independent tests complete in 6-15 seconds
56
-
57
-
## Common Tasks
58
-
59
-
### Repository Structure
60
-
```
61
-
/home/runner/work/TPEN-services/TPEN-services/
62
-
├── app.js # Express application setup
63
-
├── bin/tpen3_services.js # Server entry point
64
-
├── package.json # Dependencies and scripts
65
-
├── jest.config.js # Test configuration
66
-
├── config.env # Safe defaults (committed)
67
-
├── .env.development # Development template
68
-
├── .env.production # Production template
69
-
├── API.md # API documentation
70
-
├── classes/ # Domain model classes
71
-
│ ├── Project/ # Project management
72
-
│ ├── User/ # User management
73
-
│ ├── Group/ # Group management
74
-
│ ├── Layer/ # Annotation layers
75
-
│ ├── Line/ # Text line handling
76
-
│ ├── Page/ # Page management
77
-
│ └── Manifest/ # IIIF manifest handling
78
-
├── database/ # Database drivers
79
-
│ ├── mongo/ # MongoDB controller
80
-
│ ├── maria/ # MariaDB controller
81
-
│ └── tiny/ # TinyPEN API controller
82
-
├── auth/ # Auth0 authentication
83
-
├── project/ # Project API routes
84
-
├── userProfile/ # User API routes
85
-
├── line/ # Line API routes
86
-
├── page/ # Page API routes
87
-
└── utilities/ # Helper functions
88
-
```
89
-
90
-
### Key API Endpoints
91
-
-`GET /` -- Service status (returns "TPEN3 SERVICES BABY!!!")
92
-
-`GET /project/:id` -- Get project by ID (requires authentication)
93
-
-`POST /project/create` -- Create new project (requires authentication)
94
-
-`POST /project/import?createFrom=URL` -- Import project from IIIF manifest
95
-
-`GET /user/:id` -- Get user profile (public)
96
-
-`GET /my/profile` -- Get authenticated user profile
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
172
-
2.**Route Registration**: `npm run existsTests` passes without errors
173
-
3.**Core Logic**: `npm run unitTests` passes tests that don't require databases (some MongoDB tests will timeout - this is expected)
174
-
4.**API Authentication**: Protected endpoints like `/my/profile` return 401 status code without valid tokens
175
-
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
176
-
177
-
### Complete Validation Workflow Example
178
-
```bash
179
-
# Basic setup
180
-
cp .env.development .env
181
-
npm install
182
-
183
-
# Test core functionality without databases
184
-
npm run existsTests # Should pass completely
185
-
npm run unitTests # Should pass most tests, MongoDB tests will timeout
186
-
187
-
# Test application serving
188
-
npm start &
189
-
sleep 3
190
-
curl http://localhost:3011/ # Should return HTML with service name
191
-
curl -w "Status: %{http_code}\n" http://localhost:3011/my/profile # Should return 401
192
-
kill %1 # Stop the background server
193
-
```
194
-
195
-
### Common File Locations
196
-
- Main application entry: `bin/tpen3_services.js`
197
-
- Express app setup: `app.js`
198
-
- Route definitions: `project/index.js`, `userProfile/index.js`, etc.
@@ -238,4 +64,4 @@ kill %1 # Stop the background server
238
64
7. Use JDoc style for code documentation. Cleanup, fix, or generate documentation for the code you work on as you encounter it.
239
65
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`
240
66
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.
241
-
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`.
67
+
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`.
0 commit comments