@joystick.js/db-canary 0.0.0-canary.2209
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.build/getFilesToBuild.js +26 -0
- package/.build/getPlatformSafeFilePath.js +6 -0
- package/.build/getPlatformSafePath.js +6 -0
- package/.build/index.js +88 -0
- package/.build/isWindows.js +3 -0
- package/API_KEY +1 -0
- package/README.md +1821 -0
- package/data/data.mdb +0 -0
- package/data/lock.mdb +0 -0
- package/dist/client/database.js +1 -0
- package/dist/client/index.js +1 -0
- package/dist/server/cluster/index.js +1 -0
- package/dist/server/cluster/master.js +20 -0
- package/dist/server/cluster/worker.js +1 -0
- package/dist/server/index.js +1 -0
- package/dist/server/lib/api_key_manager.js +9 -0
- package/dist/server/lib/auth_manager.js +1 -0
- package/dist/server/lib/auto_index_manager.js +1 -0
- package/dist/server/lib/backup_manager.js +1 -0
- package/dist/server/lib/connection_manager.js +1 -0
- package/dist/server/lib/disk_utils.js +2 -0
- package/dist/server/lib/http_server.js +405 -0
- package/dist/server/lib/index_manager.js +1 -0
- package/dist/server/lib/load_settings.js +1 -0
- package/dist/server/lib/logger.js +1 -0
- package/dist/server/lib/op_types.js +1 -0
- package/dist/server/lib/operation_dispatcher.js +1 -0
- package/dist/server/lib/operations/admin.js +1 -0
- package/dist/server/lib/operations/bulk_write.js +1 -0
- package/dist/server/lib/operations/create_index.js +1 -0
- package/dist/server/lib/operations/delete_one.js +1 -0
- package/dist/server/lib/operations/drop_index.js +1 -0
- package/dist/server/lib/operations/find.js +1 -0
- package/dist/server/lib/operations/find_one.js +1 -0
- package/dist/server/lib/operations/get_indexes.js +1 -0
- package/dist/server/lib/operations/insert_one.js +1 -0
- package/dist/server/lib/operations/update_one.js +1 -0
- package/dist/server/lib/performance_monitor.js +1 -0
- package/dist/server/lib/query_engine.js +1 -0
- package/dist/server/lib/recovery_manager.js +1 -0
- package/dist/server/lib/replication_manager.js +1 -0
- package/dist/server/lib/safe_json_parse.js +1 -0
- package/dist/server/lib/send_response.js +1 -0
- package/dist/server/lib/tcp_protocol.js +1 -0
- package/dist/server/lib/write_forwarder.js +1 -0
- package/dist/server/lib/write_queue.js +1 -0
- package/increment_version.js +3 -0
- package/logs/.013e15b54597d05db4b4b53ecc37b10c92a72927-audit.json +20 -0
- package/logs/.02de550a67ea0f5961faa2dfd458a4d06f59ebd1-audit.json +20 -0
- package/logs/.03494ba24eb3c72214b4068a77d54b8993bee651-audit.json +20 -0
- package/logs/.06309ec60b339be1259a7993dd09c732f8907fbc-audit.json +20 -0
- package/logs/.0663a04dcfa17285661e5e1b8cfa51f41523b210-audit.json +20 -0
- package/logs/.0f06e6c4c9b824622729e13927587479e5060391-audit.json +20 -0
- package/logs/.16ccf58682ecb22b3e3ec63f0da1b7fe9be56528-audit.json +20 -0
- package/logs/.1fa1a5d02f496474b1ab473524c65c984146a9ad-audit.json +20 -0
- package/logs/.2223c0ae3bea6f0d62c62b1d319cc8634856abb7-audit.json +20 -0
- package/logs/.23dc79ffda3e083665e6f5993f59397adcbf4a46-audit.json +20 -0
- package/logs/.28104f49b03906b189eefd1cd462cb46c3c0af22-audit.json +20 -0
- package/logs/.29cdbf13808abe6a0ce70ee2f2efdd680ce3fd8e-audit.json +20 -0
- package/logs/.2a9889afd071f77f41f5170d08703a0afca866b7-audit.json +20 -0
- package/logs/.2acec3d1940a2bbed487528b703ee5948959a599-audit.json +20 -0
- package/logs/.2fb60ff326338c02bfedbcd0e936444e4a216750-audit.json +20 -0
- package/logs/.318fc7a19530d76a345f030f7cad00dda15300e7-audit.json +20 -0
- package/logs/.3cf27043e19085f908cedc7701e6d013463208ee-audit.json +25 -0
- package/logs/.3d90d785415817fc443402843b7c95f8371adc9b-audit.json +20 -0
- package/logs/.4074bca620375f72966fc52dfd439577727671e5-audit.json +20 -0
- package/logs/.40eecf018417ea80a70ea8ec7a3cc9406bc6334b-audit.json +20 -0
- package/logs/.50e974f1ef7c365fca6a1251b2e2c2252914cb5e-audit.json +20 -0
- package/logs/.52cb7d9e4223cf26ba36006ac26b949a97c7923c-audit.json +20 -0
- package/logs/.54befcdb84c15aad980705a31bcc9f555c3577ab-audit.json +20 -0
- package/logs/.57dfb70e22eddb84db2e3c0ceeefac5c0b9baffa-audit.json +20 -0
- package/logs/.5f0b24705a1eaad4eca4968f2d86f91b3f9be683-audit.json +20 -0
- package/logs/.61ba98fdda7db58576b382fee07904e5db1169d6-audit.json +20 -0
- package/logs/.6235017727ef6b199d569a99d6aa8c8e80a1b475-audit.json +20 -0
- package/logs/.63db16193699219489d218a1ddea5dde3750cae4-audit.json +20 -0
- package/logs/.64fb67dfe14149c9eef728d79bf30a54da809c60-audit.json +20 -0
- package/logs/.669137453368987c1f311b5345342527afb54e50-audit.json +20 -0
- package/logs/.7a71f8c89ea28ae266d356aeff6306e876a30fbb-audit.json +20 -0
- package/logs/.7afbaa90fe9dc3a7d682676f9bb79f9a1b1fd9a6-audit.json +20 -0
- package/logs/.7ca29e322cd05327035de850099e7610864f2347-audit.json +20 -0
- package/logs/.83335ab3347e449dae03455a110aaf7f120d4802-audit.json +20 -0
- package/logs/.8c2487b5fd445d2c8e5c483c80b9fa99bbf1ca58-audit.json +20 -0
- package/logs/.8c8b9dc386922c9f3b4c13251af7052aac1d24c0-audit.json +20 -0
- package/logs/.8d6155d94640c4863301ae0fee5e4e7372a21446-audit.json +20 -0
- package/logs/.944a3119a243deea7c8270d5d9e582bb1d0eaa10-audit.json +20 -0
- package/logs/.9816a845c30fb2909f3b26a23eeb3538ebcad5db-audit.json +20 -0
- package/logs/.9dc08784e38b865488177c26d4af5934555e0323-audit.json +20 -0
- package/logs/.9dd27d2e0e454ac0a37600206d1cac5493b0d7ee-audit.json +20 -0
- package/logs/.a3d486feeac7654c59b547de96600e8849a06d4f-audit.json +20 -0
- package/logs/.a5b811f4def22250f86cc18870d7c4573625df22-audit.json +20 -0
- package/logs/.a61648eb5f830e0b6f508ac35e4f8f629d2ad4c7-audit.json +20 -0
- package/logs/.a89016d507045771b4b5a65656944a9c0f1e528b-audit.json +20 -0
- package/logs/.a99bee160a1c590be959af46bacc02724803f691-audit.json +20 -0
- package/logs/.ada7906d6243fd7da802f03d86c4ae5dd9df6236-audit.json +20 -0
- package/logs/.b518339ee942143b6af983af167f5bbb6983b4de-audit.json +20 -0
- package/logs/.b51b124b166d53c9519017856ea610d61d65fabe-audit.json +20 -0
- package/logs/.b7a6aee19f58e55633d5e4a3709041c47dfff975-audit.json +20 -0
- package/logs/.bd7a8a6ba9c55d557a4867ab53f02e3ec2e1553d-audit.json +20 -0
- package/logs/.c1435dafe453b169d6392b25065f3cf4ab6fbb21-audit.json +20 -0
- package/logs/.c17e1ce043109f77dc2f0e2aa290a9d1ed842c03-audit.json +20 -0
- package/logs/.ca62637ce9540e5a38a2fbedb2115febb6ad308a-audit.json +15 -0
- package/logs/.ccee67b9c176967f8977071409a41f5cb5cd6ad4-audit.json +20 -0
- package/logs/.db24043417ea79a6f14cd947476399e53930b48d-audit.json +20 -0
- package/logs/.e0f12acccb57829f5f33712bb2e2607ecd808147-audit.json +20 -0
- package/logs/.e9b6cc33d0bbd2e644c4e2bf44d177f850016557-audit.json +20 -0
- package/logs/.f15291d434808e3bdca7963ccd2e73893be027e6-audit.json +20 -0
- package/logs/.f4bdf9e21ef84f8a3fae3ffb32bbc39275991351-audit.json +15 -0
- package/logs/.fbac3aefac1e81b4230df5aa50667cb90d51024f-audit.json +20 -0
- package/logs/.fcfd495c0a9169db243f4a4f21878ee02b76413c-audit.json +20 -0
- package/logs/admin-2025-09-12.log +580 -0
- package/logs/admin-2025-09-15.log +283 -0
- package/logs/admin-error-2025-09-12.log +22 -0
- package/logs/admin-error-2025-09-15.log +10 -0
- package/logs/api_key_manager-2025-09-12.log +658 -0
- package/logs/api_key_manager-2025-09-15.log +295 -0
- package/logs/api_key_manager-error-2025-09-12.log +0 -0
- package/logs/api_key_manager-error-2025-09-15.log +0 -0
- package/logs/auth_manager-2025-09-12.log +4432 -0
- package/logs/auth_manager-2025-09-15.log +2000 -0
- package/logs/auth_manager-error-2025-09-12.log +11 -0
- package/logs/auth_manager-error-2025-09-15.log +5 -0
- package/logs/auto_index_manager-2025-09-12.log +84 -0
- package/logs/auto_index_manager-2025-09-15.log +45 -0
- package/logs/auto_index_manager-error-2025-09-12.log +6 -0
- package/logs/auto_index_manager-error-2025-09-15.log +0 -0
- package/logs/backup_manager-2025-09-12.log +198 -0
- package/logs/backup_manager-2025-09-15.log +90 -0
- package/logs/backup_manager-error-2025-09-12.log +198 -0
- package/logs/backup_manager-error-2025-09-15.log +90 -0
- package/logs/bulk_write-2025-09-12.log +66 -0
- package/logs/bulk_write-2025-09-15.log +38 -0
- package/logs/bulk_write-error-2025-09-12.log +0 -0
- package/logs/bulk_write-error-2025-09-15.log +0 -0
- package/logs/connection_manager-2025-09-12.log +2412 -0
- package/logs/connection_manager-2025-09-15.log +1132 -0
- package/logs/connection_manager-error-2025-09-12.log +0 -0
- package/logs/connection_manager-error-2025-09-15.log +0 -0
- package/logs/create_index-2025-09-12.log +302 -0
- package/logs/create_index-2025-09-15.log +158 -0
- package/logs/create_index-error-2025-09-12.log +30 -0
- package/logs/create_index-error-2025-09-15.log +13 -0
- package/logs/delete_one-2025-09-12.log +73 -0
- package/logs/delete_one-2025-09-15.log +43 -0
- package/logs/delete_one-error-2025-09-12.log +0 -0
- package/logs/delete_one-error-2025-09-15.log +0 -0
- package/logs/disk_utils-2025-09-12.log +4954 -0
- package/logs/disk_utils-2025-09-15.log +2446 -0
- package/logs/disk_utils-error-2025-09-12.log +0 -0
- package/logs/disk_utils-error-2025-09-15.log +0 -0
- package/logs/drop_index-2025-09-12.log +41 -0
- package/logs/drop_index-2025-09-15.log +23 -0
- package/logs/drop_index-error-2025-09-12.log +11 -0
- package/logs/drop_index-error-2025-09-15.log +5 -0
- package/logs/find-2025-09-12.log +1050 -0
- package/logs/find-2025-09-15.log +592 -0
- package/logs/find-error-2025-09-12.log +1 -0
- package/logs/find-error-2025-09-15.log +0 -0
- package/logs/find_one-2025-09-12.log +425 -0
- package/logs/find_one-2025-09-15.log +264 -0
- package/logs/find_one-error-2025-09-12.log +5 -0
- package/logs/find_one-error-2025-09-15.log +0 -0
- package/logs/get_indexes-2025-09-12.log +84 -0
- package/logs/get_indexes-2025-09-15.log +56 -0
- package/logs/get_indexes-error-2025-09-12.log +6 -0
- package/logs/get_indexes-error-2025-09-15.log +0 -0
- package/logs/http_server-2025-09-12.log +2772 -0
- package/logs/http_server-2025-09-15.log +1276 -0
- package/logs/http_server-error-2025-09-12.log +212 -0
- package/logs/http_server-error-2025-09-15.log +44 -0
- package/logs/index_manager-2025-09-12.log +5031 -0
- package/logs/index_manager-2025-09-15.log +2909 -0
- package/logs/index_manager-error-2025-09-12.log +80 -0
- package/logs/index_manager-error-2025-09-15.log +38 -0
- package/logs/insert_one-2025-09-12.log +2181 -0
- package/logs/insert_one-2025-09-15.log +1293 -0
- package/logs/insert_one-error-2025-09-12.log +0 -0
- package/logs/insert_one-error-2025-09-15.log +0 -0
- package/logs/master-2025-09-12.log +1882 -0
- package/logs/master-2025-09-15.log +910 -0
- package/logs/master-error-2025-09-12.log +80 -0
- package/logs/master-error-2025-09-15.log +0 -0
- package/logs/operation_dispatcher-2025-09-12.log +751 -0
- package/logs/operation_dispatcher-2025-09-15.log +359 -0
- package/logs/operation_dispatcher-error-2025-09-12.log +33 -0
- package/logs/operation_dispatcher-error-2025-09-15.log +11 -0
- package/logs/performance_monitor-2025-09-12.log +14889 -0
- package/logs/performance_monitor-2025-09-15.log +6803 -0
- package/logs/performance_monitor-error-2025-09-12.log +0 -0
- package/logs/performance_monitor-error-2025-09-15.log +0 -0
- package/logs/query_engine-2025-09-12.log +5310 -0
- package/logs/query_engine-2025-09-15.log +2639 -0
- package/logs/query_engine-error-2025-09-12.log +0 -0
- package/logs/query_engine-error-2025-09-15.log +0 -0
- package/logs/recovery_manager-2025-09-12.log +462 -0
- package/logs/recovery_manager-2025-09-15.log +210 -0
- package/logs/recovery_manager-error-2025-09-12.log +22 -0
- package/logs/recovery_manager-error-2025-09-15.log +10 -0
- package/logs/replication-2025-09-12.log +1923 -0
- package/logs/replication-2025-09-15.log +917 -0
- package/logs/replication-error-2025-09-12.log +33 -0
- package/logs/replication-error-2025-09-15.log +15 -0
- package/logs/server-2025-09-12.log +2601 -0
- package/logs/server-2025-09-15.log +1191 -0
- package/logs/server-error-2025-09-12.log +0 -0
- package/logs/server-error-2025-09-15.log +0 -0
- package/logs/tcp_protocol-2025-09-12.log +22 -0
- package/logs/tcp_protocol-2025-09-15.log +10 -0
- package/logs/tcp_protocol-error-2025-09-12.log +22 -0
- package/logs/tcp_protocol-error-2025-09-15.log +10 -0
- package/logs/test-2025-09-12.log +0 -0
- package/logs/test-2025-09-15.log +0 -0
- package/logs/test-error-2025-09-12.log +0 -0
- package/logs/test-error-2025-09-15.log +0 -0
- package/logs/update_one-2025-09-12.log +173 -0
- package/logs/update_one-2025-09-15.log +118 -0
- package/logs/update_one-error-2025-09-12.log +0 -0
- package/logs/update_one-error-2025-09-15.log +0 -0
- package/logs/worker-2025-09-12.log +1457 -0
- package/logs/worker-2025-09-15.log +695 -0
- package/logs/worker-error-2025-09-12.log +0 -0
- package/logs/worker-error-2025-09-15.log +0 -0
- package/logs/write_forwarder-2025-09-12.log +1956 -0
- package/logs/write_forwarder-2025-09-15.log +932 -0
- package/logs/write_forwarder-error-2025-09-12.log +66 -0
- package/logs/write_forwarder-error-2025-09-15.log +30 -0
- package/logs/write_queue-2025-09-12.log +612 -0
- package/logs/write_queue-2025-09-15.log +301 -0
- package/logs/write_queue-error-2025-09-12.log +184 -0
- package/logs/write_queue-error-2025-09-15.log +83 -0
- package/package.json +48 -0
- package/prompts/01-core-infrastructure.md +56 -0
- package/prompts/02-secondary-indexing.md +65 -0
- package/prompts/03-write-serialization.md +63 -0
- package/prompts/04-enhanced-authentication.md +75 -0
- package/prompts/05-comprehensive-admin-operations.md +75 -0
- package/prompts/06-backup-and-restore-system.md +106 -0
- package/prompts/07-production-safety-features.md +107 -0
- package/prompts/08-tcp-client-library.md +121 -0
- package/prompts/09-api-method-chaining.md +134 -0
- package/prompts/10-automatic-index-creation.md +223 -0
- package/prompts/11-operation-naming-consistency.md +268 -0
- package/prompts/12-tcp-replication-system.md +333 -0
- package/prompts/13-master-read-write-operations.md +57 -0
- package/prompts/14-index-upsert-operations.md +68 -0
- package/prompts/15-client-api-return-types.md +81 -0
- package/prompts/16-server-setup-ui.md +97 -0
- package/prompts/17-emergency-password-change.md +108 -0
- package/prompts/18-joystick-framework-integration.md +116 -0
- package/prompts/19-api-key-authentication-system.md +137 -0
- package/prompts/20-configurable-server-port.md +105 -0
- package/prompts/21-multi-database-support.md +161 -0
- package/prompts/FULL_TEXT_SEARCH.md +293 -0
- package/prompts/PROMPTS.md +158 -0
- package/prompts/README.md +221 -0
- package/prompts/TYPESCRIPT_GENERATION.md +179 -0
- package/src/client/database.js +166 -0
- package/src/client/index.js +752 -0
- package/src/server/cluster/index.js +53 -0
- package/src/server/cluster/master.js +774 -0
- package/src/server/cluster/worker.js +537 -0
- package/src/server/index.js +540 -0
- package/src/server/lib/api_key_manager.js +473 -0
- package/src/server/lib/auth_manager.js +375 -0
- package/src/server/lib/auto_index_manager.js +681 -0
- package/src/server/lib/backup_manager.js +650 -0
- package/src/server/lib/connection_manager.js +218 -0
- package/src/server/lib/disk_utils.js +118 -0
- package/src/server/lib/http_server.js +1165 -0
- package/src/server/lib/index_manager.js +756 -0
- package/src/server/lib/load_settings.js +143 -0
- package/src/server/lib/logger.js +135 -0
- package/src/server/lib/op_types.js +29 -0
- package/src/server/lib/operation_dispatcher.js +268 -0
- package/src/server/lib/operations/admin.js +808 -0
- package/src/server/lib/operations/bulk_write.js +367 -0
- package/src/server/lib/operations/create_index.js +68 -0
- package/src/server/lib/operations/delete_one.js +114 -0
- package/src/server/lib/operations/drop_index.js +58 -0
- package/src/server/lib/operations/find.js +340 -0
- package/src/server/lib/operations/find_one.js +319 -0
- package/src/server/lib/operations/get_indexes.js +52 -0
- package/src/server/lib/operations/insert_one.js +113 -0
- package/src/server/lib/operations/update_one.js +225 -0
- package/src/server/lib/performance_monitor.js +313 -0
- package/src/server/lib/query_engine.js +243 -0
- package/src/server/lib/recovery_manager.js +388 -0
- package/src/server/lib/replication_manager.js +727 -0
- package/src/server/lib/safe_json_parse.js +21 -0
- package/src/server/lib/send_response.js +47 -0
- package/src/server/lib/tcp_protocol.js +130 -0
- package/src/server/lib/write_forwarder.js +636 -0
- package/src/server/lib/write_queue.js +335 -0
- package/test_data/data.mdb +0 -0
- package/test_data/lock.mdb +0 -0
- package/tests/client/index.test.js +1232 -0
- package/tests/server/cluster/cluster.test.js +248 -0
- package/tests/server/cluster/master_read_write_operations.test.js +577 -0
- package/tests/server/index.test.js +651 -0
- package/tests/server/integration/authentication_integration.test.js +294 -0
- package/tests/server/integration/auto_indexing_integration.test.js +268 -0
- package/tests/server/integration/backup_integration.test.js +513 -0
- package/tests/server/integration/indexing_integration.test.js +126 -0
- package/tests/server/integration/production_safety_integration.test.js +358 -0
- package/tests/server/integration/replication_integration.test.js +227 -0
- package/tests/server/integration/write_serialization_integration.test.js +246 -0
- package/tests/server/lib/api_key_manager.test.js +516 -0
- package/tests/server/lib/auth_manager.test.js +317 -0
- package/tests/server/lib/auto_index_manager.test.js +275 -0
- package/tests/server/lib/backup_manager.test.js +238 -0
- package/tests/server/lib/connection_manager.test.js +221 -0
- package/tests/server/lib/disk_utils.test.js +63 -0
- package/tests/server/lib/http_server.test.js +389 -0
- package/tests/server/lib/index_manager.test.js +301 -0
- package/tests/server/lib/load_settings.test.js +107 -0
- package/tests/server/lib/load_settings_port_config.test.js +243 -0
- package/tests/server/lib/logger.test.js +282 -0
- package/tests/server/lib/operations/admin.test.js +638 -0
- package/tests/server/lib/operations/bulk_write.test.js +128 -0
- package/tests/server/lib/operations/create_index.test.js +138 -0
- package/tests/server/lib/operations/delete_one.test.js +52 -0
- package/tests/server/lib/operations/drop_index.test.js +72 -0
- package/tests/server/lib/operations/find.test.js +93 -0
- package/tests/server/lib/operations/find_one.test.js +91 -0
- package/tests/server/lib/operations/get_indexes.test.js +87 -0
- package/tests/server/lib/operations/insert_one.test.js +42 -0
- package/tests/server/lib/operations/update_one.test.js +89 -0
- package/tests/server/lib/performance_monitor.test.js +185 -0
- package/tests/server/lib/query_engine.test.js +46 -0
- package/tests/server/lib/recovery_manager.test.js +414 -0
- package/tests/server/lib/replication_manager.test.js +202 -0
- package/tests/server/lib/safe_json_parse.test.js +45 -0
- package/tests/server/lib/send_response.test.js +155 -0
- package/tests/server/lib/tcp_protocol.test.js +169 -0
- package/tests/server/lib/write_forwarder.test.js +258 -0
- package/tests/server/lib/write_queue.test.js +255 -0
- package/tsconfig.json +30 -0
- package/types/client/index.d.ts +447 -0
- package/types/server/cluster/index.d.ts +28 -0
- package/types/server/cluster/master.d.ts +115 -0
- package/types/server/cluster/worker.d.ts +1 -0
- package/types/server/lib/auth_manager.d.ts +13 -0
- package/types/server/lib/backup_manager.d.ts +43 -0
- package/types/server/lib/connection_manager.d.ts +15 -0
- package/types/server/lib/disk_utils.d.ts +3 -0
- package/types/server/lib/index_manager.d.ts +24 -0
- package/types/server/lib/load_settings.d.ts +4 -0
- package/types/server/lib/logger.d.ts +44 -0
- package/types/server/lib/op_types.d.ts +6 -0
- package/types/server/lib/performance_monitor.d.ts +68 -0
- package/types/server/lib/query_engine.d.ts +10 -0
- package/types/server/lib/safe_json_parse.d.ts +7 -0
- package/types/server/lib/send_response.d.ts +3 -0
- package/types/server/lib/tcp_protocol.d.ts +12 -0
- package/types/server/lib/write_queue.d.ts +2 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# Task 17: Emergency Password Change System
|
|
2
|
+
|
|
3
|
+
## Objective
|
|
4
|
+
Implement a secure emergency password change system that allows administrators to quickly change the database password in case of security breaches or emergencies, with minimal downtime and maximum security.
|
|
5
|
+
|
|
6
|
+
## Current State
|
|
7
|
+
- Authentication system with bcrypt password hashing implemented
|
|
8
|
+
- Password stored in authentication.json file
|
|
9
|
+
- Current setup only allows initial password generation
|
|
10
|
+
- 423 passing tests from previous tasks
|
|
11
|
+
|
|
12
|
+
## Requirements
|
|
13
|
+
|
|
14
|
+
### 1. Emergency Recovery Token Generation
|
|
15
|
+
- Add CLI flag `--generate-recovery-token` to server startup
|
|
16
|
+
- When flag is used, server should:
|
|
17
|
+
- Generate cryptographically secure recovery token (UUID v4 or similar)
|
|
18
|
+
- Print recovery URL to console
|
|
19
|
+
- Exit immediately (do not start normal server operations)
|
|
20
|
+
- Example usage: `node server.js --generate-recovery-token`
|
|
21
|
+
- Example output:
|
|
22
|
+
```
|
|
23
|
+
Emergency Recovery Token Generated
|
|
24
|
+
Visit: http://localhost:1984/recovery?token=abc123def456
|
|
25
|
+
Token expires in 10 minutes
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### 2. Recovery Token Storage
|
|
29
|
+
- Store generated token temporarily with expiration timestamp
|
|
30
|
+
- Use in-memory storage or temporary file that auto-expires
|
|
31
|
+
- Token valid for 10 minutes from generation
|
|
32
|
+
- Only one recovery token can be active at a time
|
|
33
|
+
- Token automatically invalidated after first successful use
|
|
34
|
+
|
|
35
|
+
### 3. Recovery Password Change Endpoint
|
|
36
|
+
- Add HTTP endpoint `/recovery` requiring valid recovery token
|
|
37
|
+
- Validate token exists and has not expired
|
|
38
|
+
- Present simple form to enter new password
|
|
39
|
+
- Require password confirmation (enter twice)
|
|
40
|
+
- Implement password strength validation (minimum 12 characters)
|
|
41
|
+
|
|
42
|
+
### 4. Password Change Process
|
|
43
|
+
- Hash new password using existing bcrypt implementation
|
|
44
|
+
- Atomically update authentication.json file
|
|
45
|
+
- Invalidate all existing client connections (force re-authentication)
|
|
46
|
+
- Generate new authentication salt/keys if applicable
|
|
47
|
+
- Log successful password change with timestamp
|
|
48
|
+
|
|
49
|
+
### 5. Minimal Downtime Strategy
|
|
50
|
+
- Password change should not require server restart
|
|
51
|
+
- Existing connections gracefully terminated with re-auth message
|
|
52
|
+
- New connections immediately use new password
|
|
53
|
+
- Process should complete in under 30 seconds
|
|
54
|
+
- Recovery token generation does not interfere with running server
|
|
55
|
+
|
|
56
|
+
### 6. Security Measures
|
|
57
|
+
- Recovery tokens can only be generated by server administrator (CLI access)
|
|
58
|
+
- Rate limiting: only one recovery token active at a time
|
|
59
|
+
- All recovery attempts logged with IP address and timestamp
|
|
60
|
+
- Token brute force protection (lock after 3 failed attempts)
|
|
61
|
+
- Recovery token generation requires server file system access
|
|
62
|
+
|
|
63
|
+
### 7. Audit Trail
|
|
64
|
+
- Log recovery token generation attempts
|
|
65
|
+
- Log all recovery password change attempts (success/failure)
|
|
66
|
+
- Log client disconnections due to password change
|
|
67
|
+
- Maintain audit log separate from regular application logs
|
|
68
|
+
|
|
69
|
+
### 8. Recovery Instructions
|
|
70
|
+
- Provide clear instructions in response:
|
|
71
|
+
```
|
|
72
|
+
Password changed successfully!
|
|
73
|
+
|
|
74
|
+
New password is now active.
|
|
75
|
+
All existing connections have been terminated.
|
|
76
|
+
|
|
77
|
+
Next steps:
|
|
78
|
+
1. Update your app's environment settings so the client can connect using your new password
|
|
79
|
+
2. Restart or redeploy your applications to use new password
|
|
80
|
+
3. Monitor logs for any unauthorized access attempts
|
|
81
|
+
|
|
82
|
+
Recovery completed at: [timestamp]
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### 9. CLI Integration
|
|
86
|
+
- Add command line argument parsing for `--generate-recovery-token`
|
|
87
|
+
- Ensure flag works with existing server startup process
|
|
88
|
+
- Provide help text for recovery token generation
|
|
89
|
+
- Handle edge cases like server already running
|
|
90
|
+
|
|
91
|
+
## Implementation Notes
|
|
92
|
+
- Follow existing code patterns: ESM syntax, snake_case, arrow functions
|
|
93
|
+
- Maintain all existing tests (423 tests must continue passing)
|
|
94
|
+
- Add comprehensive tests for recovery token generation and password change
|
|
95
|
+
- Ensure no interference with normal server operations
|
|
96
|
+
- Use existing bcrypt and authentication utilities
|
|
97
|
+
|
|
98
|
+
## Success Criteria
|
|
99
|
+
- All existing tests pass (423 tests)
|
|
100
|
+
- `--generate-recovery-token` flag generates token and exits
|
|
101
|
+
- Recovery endpoint works with valid tokens at `/recovery`
|
|
102
|
+
- Password changes take effect immediately without server restart
|
|
103
|
+
- All existing connections terminated and require re-authentication
|
|
104
|
+
- Comprehensive audit logging of all recovery operations
|
|
105
|
+
- Token expiration and rate limiting work correctly
|
|
106
|
+
- Clear instructions provided for post-change steps
|
|
107
|
+
- No security vulnerabilities in recovery process
|
|
108
|
+
- CLI flag does not interfere with normal server startup
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# Task 18: Joystick Framework Integration - Phase 1: Migration and Setup
|
|
2
|
+
|
|
3
|
+
## Objective
|
|
4
|
+
Migrate the complete JoystickDB wrapper implementation from the standalone repository into the main Joystick framework, establishing it as an integrated database solution alongside existing database drivers.
|
|
5
|
+
|
|
6
|
+
## Current State
|
|
7
|
+
- Complete JoystickDB implementation with 474 passing tests
|
|
8
|
+
- Standalone Node.js wrapper around LMDB with TCP server/client architecture
|
|
9
|
+
- Full production-grade features: authentication, clustering, replication, backup/restore
|
|
10
|
+
- Located at: `/Users/rglover/projects/cheatcode/joystick-db`
|
|
11
|
+
- Target integration: `/Users/rglover/projects/cheatcode/joystick` framework
|
|
12
|
+
|
|
13
|
+
## Phase 1 Requirements: Migration and Structure Setup
|
|
14
|
+
|
|
15
|
+
### 1. Repository Migration
|
|
16
|
+
- **Source**: `/Users/rglover/projects/cheatcode/joystick-db`
|
|
17
|
+
- **Target**: `/Users/rglover/projects/cheatcode/joystick/db`
|
|
18
|
+
- Migrate entire source tree maintaining directory structure
|
|
19
|
+
- Preserve all existing functionality and tests
|
|
20
|
+
- Maintain git history where possible
|
|
21
|
+
|
|
22
|
+
### 2. Framework Integration Structure
|
|
23
|
+
- Study existing database packages in `/Users/rglover/projects/cheatcode/joystick`
|
|
24
|
+
- Mimic established patterns for:
|
|
25
|
+
- Package structure and organization
|
|
26
|
+
- Build and release processes
|
|
27
|
+
- Canary release behavior
|
|
28
|
+
- Configuration management
|
|
29
|
+
- Integration points with CLI and node back-end
|
|
30
|
+
|
|
31
|
+
### 3. Package Configuration
|
|
32
|
+
- Update `package.json` to match framework conventions
|
|
33
|
+
- Establish proper dependencies and peer dependencies
|
|
34
|
+
- Configure build scripts and testing workflows
|
|
35
|
+
- Set up canary release pipeline integration
|
|
36
|
+
|
|
37
|
+
### 4. Branch Management
|
|
38
|
+
- Create feature branch: `feature/joystick-db-integration`
|
|
39
|
+
- All work must be done in this branch
|
|
40
|
+
- No direct commits to master or canary branch
|
|
41
|
+
|
|
42
|
+
## Architecture Changes for Integration
|
|
43
|
+
|
|
44
|
+
### 1. Database Server Process Management
|
|
45
|
+
- **Current**: Direct LMDB wrapper execution
|
|
46
|
+
- **Target**: Child process management for database server
|
|
47
|
+
- Server startup via `src/server/index.js` as separate process
|
|
48
|
+
- Process lifecycle management (start, stop, restart, health checks)
|
|
49
|
+
- Integration with framework's process management system
|
|
50
|
+
|
|
51
|
+
### 2. Client Driver Implementation
|
|
52
|
+
- Implement JoystickDB as a database driver in the node portion
|
|
53
|
+
- Follow existing driver patterns and interfaces
|
|
54
|
+
- Provide seamless integration with framework's ORM/query builder
|
|
55
|
+
- Maintain compatibility with existing JoystickDB client API
|
|
56
|
+
- Add support for accounts and queues to the JoystickDB integration (just like MongoDB and PostgreSQL).
|
|
57
|
+
|
|
58
|
+
### 3. CLI Integration Points
|
|
59
|
+
- Database management commands
|
|
60
|
+
- Server lifecycle controls (start, stop, status)
|
|
61
|
+
- Migration and setup utilities
|
|
62
|
+
- Configuration management through CLI
|
|
63
|
+
|
|
64
|
+
## Implementation Guidelines
|
|
65
|
+
|
|
66
|
+
### Code Standards
|
|
67
|
+
- Follow Joystick framework conventions
|
|
68
|
+
- Maintain existing JoystickDB code patterns where compatible
|
|
69
|
+
- Use ESM syntax (`import`/`export`)
|
|
70
|
+
- Follow snake_case for variables, functions, and keys
|
|
71
|
+
- Two-space indentation
|
|
72
|
+
- Minimal comments (only when necessary for clarity)
|
|
73
|
+
|
|
74
|
+
### Testing Requirements
|
|
75
|
+
- All existing JoystickDB tests (474) must continue to pass
|
|
76
|
+
- Add integration tests for framework compatibility
|
|
77
|
+
- Test child process management and lifecycle
|
|
78
|
+
- Verify CLI integration points
|
|
79
|
+
- Retain usage of Ava.js for authoring tests (do not modify the existing tests beyond ensuring they test the correct code within the joystick/db folder).
|
|
80
|
+
|
|
81
|
+
### Dependencies Management
|
|
82
|
+
- Integrate with framework's dependency management
|
|
83
|
+
- Maintain JoystickDB-specific dependencies: `lmdb`, `msgpackr`, `bcrypt`, `@aws-sdk/client-s3`
|
|
84
|
+
- Resolve any conflicts with framework dependencies
|
|
85
|
+
- Update peer dependencies as needed
|
|
86
|
+
|
|
87
|
+
## Success Criteria - Phase 1
|
|
88
|
+
- ✅ Complete source migration to `/Users/rglover/projects/cheatcode/joystick/db`
|
|
89
|
+
- ✅ All 474 existing tests continue to pass in new location
|
|
90
|
+
- ✅ Package structure matches framework conventions
|
|
91
|
+
- ✅ Canary release pipeline configured
|
|
92
|
+
- ✅ Build and development workflows operational
|
|
93
|
+
- ✅ Branch created and all work isolated properly
|
|
94
|
+
|
|
95
|
+
## Future Phases (Separate Tasks/Chats)
|
|
96
|
+
|
|
97
|
+
### Phase 2: Process Management Integration
|
|
98
|
+
- Implement child process management for database server
|
|
99
|
+
- CLI commands for server lifecycle management
|
|
100
|
+
- Health monitoring and automatic restart capabilities
|
|
101
|
+
|
|
102
|
+
### Phase 3: Driver Implementation
|
|
103
|
+
- Create JoystickDB driver for framework's node back-end
|
|
104
|
+
- Integrate with existing ORM/query patterns
|
|
105
|
+
- Provide migration utilities and setup commands
|
|
106
|
+
|
|
107
|
+
## Notes
|
|
108
|
+
- This is Phase 1 of a multi-phase integration
|
|
109
|
+
- Focus on migration and structural setup only
|
|
110
|
+
- Preserve all existing functionality during migration
|
|
111
|
+
- Each phase will require a new prompt and potentially new chat session
|
|
112
|
+
- Integration must not break existing framework functionality
|
|
113
|
+
- JoystickDB should be additive to the framework's capabilities
|
|
114
|
+
|
|
115
|
+
## Context for Next Phase
|
|
116
|
+
After Phase 1 completion, the next phase will focus on implementing child process management to replace the current binary download pattern used by other database drivers. This will require careful integration with the framework's process management system and CLI tooling.
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# Task 19: API Key Authentication System
|
|
2
|
+
|
|
3
|
+
## Objective
|
|
4
|
+
Implement an API key-based authentication system that eliminates auto-generated passwords, provides secure database initialization with API keys, and enables user management through HTTP APIs.
|
|
5
|
+
|
|
6
|
+
## Current State
|
|
7
|
+
- Enhanced authentication system with password management
|
|
8
|
+
- HTTP server setup UI with token-based security
|
|
9
|
+
- TCP server with MessagePack protocol
|
|
10
|
+
- HTTP server for setup operations
|
|
11
|
+
- 423 passing tests from previous tasks
|
|
12
|
+
|
|
13
|
+
## Requirements
|
|
14
|
+
|
|
15
|
+
### 1. API Key File Generation
|
|
16
|
+
- Remove all auto-password generation functionality
|
|
17
|
+
- On server startup, check for existing `API_KEY` file in root directory
|
|
18
|
+
- If no `API_KEY` file exists, generate random API key (32-character alphanumeric)
|
|
19
|
+
- Create `API_KEY` file with generated key
|
|
20
|
+
- Display clear startup message:
|
|
21
|
+
```
|
|
22
|
+
JoystickDB Setup
|
|
23
|
+
|
|
24
|
+
To finish setting up your database and enable operations for authenticated users, you will need to create an admin user via the database's admin API using the API key displayed below.
|
|
25
|
+
|
|
26
|
+
=== STORE THIS KEY SECURELY -- IT WILL NOT BE DISPLAYED AGAIN ===
|
|
27
|
+
[api_key_here]
|
|
28
|
+
===
|
|
29
|
+
|
|
30
|
+
To create a user, send a POST request to the server:
|
|
31
|
+
|
|
32
|
+
<example POST request to http://localhost:<database_port>/api/users via fetch() with the API key stored in the x-joystick-db-api-key header>
|
|
33
|
+
|
|
34
|
+
==!==
|
|
35
|
+
Store this key securely. It will not be displayed again.
|
|
36
|
+
==!==
|
|
37
|
+
|
|
38
|
+
API key saved to: ./API_KEY
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 2. Pre-Setup Authentication
|
|
42
|
+
- All HTTP requests must include `x-joystick-db-api-key` header
|
|
43
|
+
- Validate header against contents of `API_KEY` file
|
|
44
|
+
- Return 403 Forbidden for requests without valid API key:
|
|
45
|
+
```json
|
|
46
|
+
{
|
|
47
|
+
"error": "Database setup incomplete. A valid API key must be passed until an admin user has been created."
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
- Only allow requests with valid API key until admin user exists
|
|
51
|
+
|
|
52
|
+
### 3. User Management HTTP API
|
|
53
|
+
- Remove existing setup UI in favor of HTTP API endpoints
|
|
54
|
+
- Add `/api/users` endpoint for user management operations
|
|
55
|
+
- Support user creation with username, password, and role
|
|
56
|
+
- Available roles: `read`, `write`, `read_write`
|
|
57
|
+
- All endpoints require valid `x-joystick-db-api-key` header
|
|
58
|
+
|
|
59
|
+
### 4. User Creation Endpoint
|
|
60
|
+
- `POST /api/users` - Create new user
|
|
61
|
+
- Request body:
|
|
62
|
+
```json
|
|
63
|
+
{
|
|
64
|
+
"username": "admin",
|
|
65
|
+
"password": "secure_password",
|
|
66
|
+
"role": "read_write"
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
- Response format:
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"ok": 1,
|
|
73
|
+
"user": {
|
|
74
|
+
"username": "admin",
|
|
75
|
+
"role": "read_write",
|
|
76
|
+
"created_at": "2025-08-30T19:00:00.000Z"
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### 5. User Management Operations
|
|
82
|
+
- `GET /api/users` - List all users (admin only)
|
|
83
|
+
- `PUT /api/users/:username` - Update user role/password
|
|
84
|
+
- `DELETE /api/users/:username` - Delete user
|
|
85
|
+
- All operations require valid API key header
|
|
86
|
+
- Implement proper role-based access control
|
|
87
|
+
|
|
88
|
+
### 6. Admin User Detection
|
|
89
|
+
- Track when first admin user (role: `read_write`) is created
|
|
90
|
+
- After admin user creation, API key requirement can be relaxed for authenticated operations (API key is still required for the /api/<resource> routes but normal TCP-based database operations with valid auth can pass through).
|
|
91
|
+
- Transition to standard user authentication for subsequent requests
|
|
92
|
+
- Maintain API key requirement for user management operations
|
|
93
|
+
|
|
94
|
+
### 7. Security Enhancements
|
|
95
|
+
- Store user data in the database itself in a _users collection.
|
|
96
|
+
- Hash passwords using bcrypt with proper salt rounds
|
|
97
|
+
- Implement rate limiting for user creation attempts
|
|
98
|
+
- Add audit logging for all user management operations
|
|
99
|
+
- Secure file permissions for API_KEY
|
|
100
|
+
|
|
101
|
+
### 8. Error Handling and Validation
|
|
102
|
+
- Validate username format (alphanumeric, 3-50 characters)
|
|
103
|
+
- Enforce password complexity requirements
|
|
104
|
+
- Validate role values against allowed options
|
|
105
|
+
- Return descriptive error messages for validation failures
|
|
106
|
+
- Handle duplicate username attempts gracefully
|
|
107
|
+
|
|
108
|
+
## Implementation Notes
|
|
109
|
+
- Follow existing code patterns: ESM syntax, snake_case, arrow functions
|
|
110
|
+
- Write small, single-purpose functions with max 4 arguments (combine into objects if needed)
|
|
111
|
+
- Use clear, full names for maintainability - no shorthand or clever naming
|
|
112
|
+
- Always use two-space indentation
|
|
113
|
+
- Always use arrow functions unless function() required for scope
|
|
114
|
+
- Avoid usage of this unless required (inside classes) or technically necessary
|
|
115
|
+
- Always use snake_case for function names, argument names, and variable names
|
|
116
|
+
- Always use closing semicolons
|
|
117
|
+
- Always use ESM JavaScript (import instead of require)
|
|
118
|
+
- Use default exports for single functions/modules, named exports for multiple
|
|
119
|
+
- DO NOT write unnecessary comments
|
|
120
|
+
- When comments are needed, use proper grammar and prefix with `// NOTE:`
|
|
121
|
+
- Maintain all existing tests (423 tests must continue passing)
|
|
122
|
+
- Add comprehensive tests for API key validation and user management
|
|
123
|
+
- Remove password auto-generation from all existing code paths
|
|
124
|
+
- Ensure atomic file operations for user data persistence
|
|
125
|
+
|
|
126
|
+
## Success Criteria
|
|
127
|
+
- All existing tests pass (423 tests)
|
|
128
|
+
- API_KEY file generated on first startup
|
|
129
|
+
- Clear startup message displays generated API key
|
|
130
|
+
- HTTP requests require valid x-joystick-db-api-key header
|
|
131
|
+
- 403 Forbidden returned for invalid/missing API keys
|
|
132
|
+
- User creation endpoint accepts username, password, and role
|
|
133
|
+
- User management operations work through HTTP API
|
|
134
|
+
- No auto-generated passwords in any code path
|
|
135
|
+
- Secure file handling for API keys and user data
|
|
136
|
+
- Proper role-based access control implemented
|
|
137
|
+
- Admin user detection triggers authentication transition
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Task 20: Configurable Server Port
|
|
2
|
+
|
|
3
|
+
## Objective
|
|
4
|
+
Make the server port configurable through the `process.env.JOYSTICK_DB_SETTINGS` environment variable instead of being hardcoded, allowing flexible deployment configurations.
|
|
5
|
+
|
|
6
|
+
## Current State
|
|
7
|
+
- TCP server currently hardcoded to port 1983
|
|
8
|
+
- HTTP server currently hardcoded to port 1984
|
|
9
|
+
- Port configuration handled through command line arguments and environment variables
|
|
10
|
+
- 423 passing tests from previous tasks
|
|
11
|
+
- API key authentication system with HTTP endpoints
|
|
12
|
+
|
|
13
|
+
## Requirements
|
|
14
|
+
|
|
15
|
+
### 1. Settings-Based Port Configuration
|
|
16
|
+
- Remove hardcoded port values (1983 for TCP, 1984 for HTTP)
|
|
17
|
+
- Read port configuration from `process.env.JOYSTICK_DB_SETTINGS` JSON object
|
|
18
|
+
- Support single `port` setting for TCP server
|
|
19
|
+
- HTTP server port automatically calculated as `port + 1`
|
|
20
|
+
- Maintain backward compatibility with existing `PORT` environment variable
|
|
21
|
+
- Default value: TCP port 1983 (HTTP port 1984) if not specified
|
|
22
|
+
|
|
23
|
+
### 2. Settings Schema Extension
|
|
24
|
+
- Extend settings schema to include:
|
|
25
|
+
```json
|
|
26
|
+
{
|
|
27
|
+
"port": 1983,
|
|
28
|
+
"authentication": { ... },
|
|
29
|
+
"s3": { ... },
|
|
30
|
+
"replication": { ... }
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
- Validate port number (1024-65534 range to allow for HTTP port + 1)
|
|
34
|
+
- Ensure HTTP port (port + 1) doesn't exceed 65535
|
|
35
|
+
|
|
36
|
+
### 3. Port Resolution Priority
|
|
37
|
+
- Priority order for TCP port:
|
|
38
|
+
1. `JOYSTICK_DB_SETTINGS.port`
|
|
39
|
+
2. Default: 1983
|
|
40
|
+
- HTTP port always calculated as: `tcp_port + 1`
|
|
41
|
+
|
|
42
|
+
### 4. Server Startup Updates
|
|
43
|
+
- Update `create_server()` function to read port from settings
|
|
44
|
+
- Update cluster startup to use configured port
|
|
45
|
+
- Update HTTP server initialization to use `port + 1`
|
|
46
|
+
- Ensure proper error handling for port conflicts
|
|
47
|
+
|
|
48
|
+
### 5. Logging and Diagnostics
|
|
49
|
+
- Log configured ports during server startup
|
|
50
|
+
- Include both TCP and HTTP port information in server status messages
|
|
51
|
+
- Update startup messages to show actual ports being used
|
|
52
|
+
- Add port validation warnings for invalid configurations
|
|
53
|
+
|
|
54
|
+
### 6. Settings Validation
|
|
55
|
+
- Validate port number is integer within valid range (1024-65534)
|
|
56
|
+
- Ensure HTTP port (port + 1) doesn't exceed maximum port number (65535)
|
|
57
|
+
- Provide clear error messages for invalid port configurations
|
|
58
|
+
- Handle edge cases like ports already in use
|
|
59
|
+
|
|
60
|
+
### 7. Backward Compatibility
|
|
61
|
+
- Maintain support for existing `PORT` environment variable
|
|
62
|
+
- Ensure existing deployment scripts continue working
|
|
63
|
+
- Keep command line argument support for port specification
|
|
64
|
+
- Preserve existing test configurations
|
|
65
|
+
|
|
66
|
+
### 8. Configuration Examples
|
|
67
|
+
- Document settings format in startup messages:
|
|
68
|
+
```bash
|
|
69
|
+
export JOYSTICK_DB_SETTINGS='{"port": 3000}'
|
|
70
|
+
# TCP server: 3000, HTTP server: 3001
|
|
71
|
+
```
|
|
72
|
+
- Support common deployment scenarios:
|
|
73
|
+
- Development: default port 1983 (HTTP: 1984)
|
|
74
|
+
- Production: custom port via settings
|
|
75
|
+
- Docker: environment-based configuration
|
|
76
|
+
- Kubernetes: configmap-based settings
|
|
77
|
+
|
|
78
|
+
## Implementation Notes
|
|
79
|
+
- Follow existing code patterns: ESM syntax, snake_case, arrow functions
|
|
80
|
+
- Write small, single-purpose functions with max 4 arguments (combine into objects if needed)
|
|
81
|
+
- Use clear, full names for maintainability - no shorthand or clever naming
|
|
82
|
+
- Always use two-space indentation
|
|
83
|
+
- Always use arrow functions unless function() required for scope
|
|
84
|
+
- Avoid usage of this unless required (inside classes) or technically necessary
|
|
85
|
+
- Always use snake_case for function names, argument names, and variable names
|
|
86
|
+
- Always use closing semicolons
|
|
87
|
+
- Always use ESM JavaScript (import instead of require)
|
|
88
|
+
- Use default exports for single functions/modules, named exports for multiple
|
|
89
|
+
- DO NOT write unnecessary comments
|
|
90
|
+
- When comments are needed, use proper grammar and prefix with `// NOTE:`
|
|
91
|
+
- Maintain all existing tests (423 tests must continue passing)
|
|
92
|
+
- Add comprehensive tests for port configuration scenarios
|
|
93
|
+
- Update existing port-related tests to use configurable ports
|
|
94
|
+
- Ensure atomic configuration loading and validation
|
|
95
|
+
|
|
96
|
+
## Success Criteria
|
|
97
|
+
- All existing tests pass (423 tests)
|
|
98
|
+
- TCP server port configurable via `JOYSTICK_DB_SETTINGS.port`
|
|
99
|
+
- HTTP server port automatically set to `port + 1`
|
|
100
|
+
- Port validation prevents invalid configurations (including HTTP port overflow)
|
|
101
|
+
- Clear startup logging shows both TCP and HTTP ports
|
|
102
|
+
- Settings reload updates port configuration appropriately
|
|
103
|
+
- Comprehensive test coverage for all port configuration scenarios
|
|
104
|
+
- Documentation updated with configuration examples
|
|
105
|
+
- Error handling for port conflicts and invalid values
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# Task 21: Multi-Database Support
|
|
2
|
+
|
|
3
|
+
## Objective
|
|
4
|
+
Implement multi-database support that allows multiple databases to run on a single server instance, providing a MongoDB-like chaining API for database and collection selection: `client.db('database_name').collection('collection_name').find()`.
|
|
5
|
+
|
|
6
|
+
## Current State
|
|
7
|
+
- Single database per server instance
|
|
8
|
+
- Collection-based chaining API: `client.collection('name').find()`
|
|
9
|
+
- TCP server on port 1983 with MessagePack protocol
|
|
10
|
+
- HTTP server on port 1984 for setup operations
|
|
11
|
+
- API key authentication system
|
|
12
|
+
- All existing CRUD, indexing, admin, backup, and replication operations
|
|
13
|
+
- 423+ passing tests from previous tasks
|
|
14
|
+
|
|
15
|
+
## Requirements
|
|
16
|
+
|
|
17
|
+
### 1. Multi-Database Architecture
|
|
18
|
+
- Enable multiple databases to coexist on a single server instance
|
|
19
|
+
- Each database maintains its own collections, indexes, and data isolation
|
|
20
|
+
- Database names follow MongoDB naming conventions (alphanumeric, underscores, hyphens)
|
|
21
|
+
- Maximum database name length of 64 characters
|
|
22
|
+
- Reserved database names: `admin`, `config`, `local`
|
|
23
|
+
|
|
24
|
+
### 2. Enhanced Client API
|
|
25
|
+
- Replace current API with database selection via chaining
|
|
26
|
+
- New API pattern: `client.db('database_name').collection('collection_name').find()`
|
|
27
|
+
- Database selection returns a Database interface for further chaining
|
|
28
|
+
- Collection selection from Database interface returns Collection interface
|
|
29
|
+
- Remove direct `client.collection()` method - all operations must specify database
|
|
30
|
+
|
|
31
|
+
### 3. Database Interface Implementation
|
|
32
|
+
```javascript
|
|
33
|
+
// New chaining API examples:
|
|
34
|
+
const client = joystickdb.client({ password: 'password' });
|
|
35
|
+
|
|
36
|
+
// Multi-database operations
|
|
37
|
+
const results = await client.db('analytics').collection('events').find();
|
|
38
|
+
const user = await client.db('users').collection('profiles').find_one({ email: 'user@example.com' });
|
|
39
|
+
|
|
40
|
+
// Database-level operations
|
|
41
|
+
const db = client.db('analytics');
|
|
42
|
+
const collections = await db.list_collections();
|
|
43
|
+
const stats = await db.get_stats();
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 4. Database Class Implementation
|
|
47
|
+
- Create Database class similar to existing Collection class
|
|
48
|
+
- Database class methods:
|
|
49
|
+
- `collection(name)` - Returns Collection interface for the database
|
|
50
|
+
- `list_collections()` - Lists collections in the database
|
|
51
|
+
- `get_stats()` - Gets database-specific statistics
|
|
52
|
+
- `drop_database()` - Drops the entire database (admin operation)
|
|
53
|
+
- `create_collection(name, options)` - Explicitly creates a collection
|
|
54
|
+
|
|
55
|
+
### 5. Updated Collection Class
|
|
56
|
+
- Collection class now requires database context
|
|
57
|
+
- All existing Collection methods remain the same
|
|
58
|
+
- Collection operations are scoped to the parent database
|
|
59
|
+
- Constructor: `new Collection(client, database_name, collection_name)`
|
|
60
|
+
|
|
61
|
+
### 6. Server-Side Database Management
|
|
62
|
+
- Modify server to handle database context in all operations
|
|
63
|
+
- Update message protocol to include database name in requests
|
|
64
|
+
- Database creation on-demand (similar to MongoDB behavior)
|
|
65
|
+
- Database isolation in file system storage
|
|
66
|
+
- Update all existing operations to be database-aware
|
|
67
|
+
|
|
68
|
+
### 7. Protocol Updates
|
|
69
|
+
- Extend MessagePack protocol to include `database` field in requests
|
|
70
|
+
- Request format:
|
|
71
|
+
```javascript
|
|
72
|
+
{
|
|
73
|
+
op: 'find',
|
|
74
|
+
database: 'analytics', // Required field
|
|
75
|
+
data: {
|
|
76
|
+
collection: 'events',
|
|
77
|
+
filter: {},
|
|
78
|
+
options: {}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
- All requests must include database field
|
|
83
|
+
|
|
84
|
+
### 8. Storage Layer Updates
|
|
85
|
+
- Organize data files by database: `data/{database_name}/{collection_name}.json`
|
|
86
|
+
- Organize index files by database: `indexes/{database_name}/{collection_name}/`
|
|
87
|
+
- Organize backup files by database: `backups/{database_name}/`
|
|
88
|
+
- Atomic operations across database boundaries when needed
|
|
89
|
+
|
|
90
|
+
### 9. Admin Operations Enhancement
|
|
91
|
+
- Update admin operations to be database-aware
|
|
92
|
+
- New admin operations:
|
|
93
|
+
- `list_databases` - Lists all databases on server
|
|
94
|
+
- `get_database_stats` - Gets statistics for specific database
|
|
95
|
+
- `drop_database` - Removes entire database and all collections
|
|
96
|
+
- `copy_database` - Copies database to new name
|
|
97
|
+
- All admin operations require database context
|
|
98
|
+
|
|
99
|
+
### 10. Authentication and Authorization
|
|
100
|
+
- Maintain existing authentication system
|
|
101
|
+
- Database access controlled by existing user roles
|
|
102
|
+
- All authenticated users can access all databases
|
|
103
|
+
- Future enhancement: database-specific permissions (not in this task)
|
|
104
|
+
|
|
105
|
+
### 11. Backup and Restore Updates
|
|
106
|
+
- Backup operations can target specific databases
|
|
107
|
+
- Full server backup includes all databases
|
|
108
|
+
- Restore operations can target specific databases
|
|
109
|
+
- Backup file naming: `backup_{database_name}_{timestamp}.json`
|
|
110
|
+
- Full backup naming: `backup_full_{timestamp}.json`
|
|
111
|
+
|
|
112
|
+
### 12. Replication Updates
|
|
113
|
+
- Replication system replicates all databases
|
|
114
|
+
- Database-specific replication filtering (future enhancement)
|
|
115
|
+
- Update replication protocol with database context
|
|
116
|
+
|
|
117
|
+
### 13. Error Handling and Validation
|
|
118
|
+
- Validate database names against naming rules
|
|
119
|
+
- Handle database not found scenarios gracefully
|
|
120
|
+
- Add database context to error messages where relevant
|
|
121
|
+
- Return clear errors when database field is missing from requests
|
|
122
|
+
|
|
123
|
+
## Implementation Notes
|
|
124
|
+
- Follow existing code patterns: ESM syntax, snake_case, arrow functions
|
|
125
|
+
- Write small, single-purpose functions with max 4 arguments (combine into objects if needed)
|
|
126
|
+
- Use clear, full names for maintainability - no shorthand or clever naming
|
|
127
|
+
- Always use two-space indentation
|
|
128
|
+
- Always use arrow functions unless function() required for scope
|
|
129
|
+
- Avoid usage of this unless required (inside classes) or technically necessary
|
|
130
|
+
- Always use snake_case for function names, argument names, and variable names
|
|
131
|
+
- Always use closing semicolons
|
|
132
|
+
- Always use ESM JavaScript (import instead of require)
|
|
133
|
+
- Use default exports for single functions/modules, named exports for multiple
|
|
134
|
+
- DO NOT write unnecessary comments
|
|
135
|
+
- When comments are needed, use proper grammar and prefix with `// NOTE:`
|
|
136
|
+
- Update all existing tests to use new API pattern
|
|
137
|
+
- Add comprehensive tests for multi-database functionality
|
|
138
|
+
- Database operations should be atomic and consistent
|
|
139
|
+
|
|
140
|
+
## API Changes Required
|
|
141
|
+
- Remove `client.collection(name)` method from JoystickDBClient class
|
|
142
|
+
- Add `client.db(name)` method that returns Database instance
|
|
143
|
+
- Update all client methods to require database context
|
|
144
|
+
- Update Collection class constructor to accept database_name parameter
|
|
145
|
+
- All operations must specify both database and collection
|
|
146
|
+
|
|
147
|
+
## Success Criteria
|
|
148
|
+
- All tests updated and passing with new API pattern
|
|
149
|
+
- New Database class provides database-level operations
|
|
150
|
+
- Client supports `client.db('name').collection('name')` chaining exclusively
|
|
151
|
+
- Multiple databases can coexist on single server
|
|
152
|
+
- Database isolation: operations in one database don't affect others
|
|
153
|
+
- On-demand database creation (no explicit database creation required)
|
|
154
|
+
- Admin operations support database-specific and server-wide operations
|
|
155
|
+
- Backup and restore operations support database-specific targeting
|
|
156
|
+
- Replication system handles multiple databases
|
|
157
|
+
- File system organization supports multiple databases
|
|
158
|
+
- Protocol requires database field in all requests
|
|
159
|
+
- Comprehensive test coverage for multi-database scenarios
|
|
160
|
+
- Clear error messages with database context
|
|
161
|
+
- All existing functionality preserved within new API structure
|