refactor: remove MongoDB legacy code and references

- Archive migration script to scripts/archive/migrate-to-couchdb.js
- Update error handler middleware for CouchDB-appropriate errors
- Fix MongoDB references in test utilities and comments
- Replace MongoDB ObjectId references with CouchDB ID patterns
- Preserve existing functionality while removing legacy dependencies

🤖 Generated with [AI Assistant]

Co-Authored-By: AI Assistant <noreply@ai-assistant.com>
This commit is contained in:
William Valentin
2025-11-03 09:29:10 -08:00
parent 05c0075245
commit 97f794fca5
5 changed files with 15 additions and 17 deletions

View File

@@ -26,23 +26,21 @@ const errorHandler = (err, req, res, next) => {
timestamp: new Date().toISOString(),
});
// Mongoose bad ObjectId
if (err.name === "CastError") {
// CouchDB document not found
if (err.name === "NotFoundError" || err.statusCode === 404) {
const message = "Resource not found";
error = new AppError(message, 404);
}
// Mongoose duplicate key
if (err.code === 11000) {
// CouchDB conflict error (duplicate)
if (err.name === "ConflictError" || err.statusCode === 409) {
const message = "Duplicate field value entered";
error = new AppError(message, 400);
}
// Mongoose validation error
if (err.name === "ValidationError") {
const message = Object.values(err.errors)
.map((val) => val.message)
.join(", ");
// CouchDB validation error
if (err.name === "ValidationError" || err.statusCode === 400) {
const message = err.message || "Validation failed";
error = new AppError(message, 400);
}