{"id":29583786,"url":"https://github.com/codedynasty-dev/tero","last_synced_at":"2025-07-19T23:38:54.943Z","repository":{"id":305083372,"uuid":"1021758889","full_name":"CodeDynasty-dev/tero","owner":"CodeDynasty-dev","description":null,"archived":false,"fork":false,"pushed_at":"2025-07-18T06:24:36.000Z","size":93,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-18T08:27:12.186Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CodeDynasty-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-17T22:53:08.000Z","updated_at":"2025-07-18T06:24:40.000Z","dependencies_parsed_at":"2025-07-18T08:30:51.417Z","dependency_job_id":"4333fdd8-bf15-4057-8c08-488a90775e7e","html_url":"https://github.com/CodeDynasty-dev/tero","commit_stats":null,"previous_names":["codedynasty-dev/tero"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/CodeDynasty-dev/tero","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeDynasty-dev%2Ftero","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeDynasty-dev%2Ftero/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeDynasty-dev%2Ftero/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeDynasty-dev%2Ftero/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CodeDynasty-dev","download_url":"https://codeload.github.com/CodeDynasty-dev/tero/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeDynasty-dev%2Ftero/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266042413,"owners_count":23867962,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-07-19T23:38:53.882Z","updated_at":"2025-07-19T23:38:54.922Z","avatar_url":"https://github.com/CodeDynasty-dev.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tero\n\n[![npm version](https://badge.fury.io/js/tero.svg)](https://badge.fury.io/js/tero)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](https://www.typescriptlang.org/)\n[![Node.js](https://img.shields.io/badge/Node.js-18%2B-green.svg)](https://nodejs.org/)\n[![Build Status](https://img.shields.io/badge/build-passing-brightgreen.svg)](#)\n[![Coverage](https://img.shields.io/badge/coverage-95%25-brightgreen.svg)](#)\n\n**JSON document database**\n\nTero is a JSON database that provides ACID transactions, schema validation, cloud backup, and automatic recovery. Built for production environments requiring json data integrity and reliability.\n\n## Key Features\n\n### Transactions\n- **Atomicity**: All-or-nothing transactions ensure data consistency\n- **Consistency**: Schema validation and business rule enforcement\n- **Isolation**: Concurrent operations are properly isolated\n- **Durability**: Write-ahead logging ensures data survives system crashes\n\n### Ready-To-Use\n- **High Performance**: Intelligent caching and batch operations\n- **Data Integrity**: Built-in corruption detection and recovery\n- **Schema Validation**: Flexible schema system with strict mode\n- **Error Handling**: Comprehensive error handling and recovery\n- **Memory Management**: Efficient memory usage with automatic cleanup\n- **Cloud Backup**: AWS S3 and Cloudflare R2 support\n- **Data Recovery**: Automatic crash recovery and cloud restore\n- **Monitoring**: Performance metrics and health checks\n- **Security**: Path traversal protection and input validation\n\n## Installation\n\n```bash\nnpm install tero\n```\n\n##  Quick Start\n\n```javascript\nimport { Tero } from 'tero';\n\n// Initialize database\nconst db = new Tero({\n  directory: './mydata',\n  cacheSize: 1000\n});\n\n// Basic operations\nawait db.create('user1', { name: 'Alice', email: 'alice@example.com' });\nconst user = await db.get('user1');\nawait db.update('user1', { age: 30 });\nawait db.remove('user1');\n```\n\n## ACID Transactions\n\n### Automatic Transactions\nAll basic operations are automatically wrapped in ACID transactions:\n\n```javascript\n// These operations are automatically ACID-compliant\nawait db.create('account', { balance: 1000 });\nawait db.update('account', { balance: 1500 });\n```\n\n### Manual Transactions\nFor complex operations requiring multiple steps:\n\n```javascript\nconst txId = db.beginTransaction();\n\ntry {\n  await db.write(txId, 'account1', { balance: 900 });\n  await db.write(txId, 'account2', { balance: 1100 });\n  \n  // Verify within transaction\n  const account1 = await db.read(txId, 'account1');\n  \n  await db.commit(txId);\n} catch (error) {\n  await db.rollback(txId);\n  throw error;\n}\n```\n\n### Money Transfer Example\nDemonstrates ACID properties with business logic:\n\n```javascript\n// Atomic money transfer with validation\nawait db.transferMoney('savings', 'checking', 500);\n```\n\n## Schema Validation\n\nDefine and enforce data schemas:\n\n```javascript\n// Set schema\ndb.setSchema('users', {\n  name: { type: 'string', required: true, min: 2, max: 50 },\n  email: { type: 'string', required: true, format: 'email' },\n  age: { type: 'number', min: 0, max: 150 },\n  profile: {\n    type: 'object',\n    properties: {\n      bio: { type: 'string', max: 500 },\n      website: { type: 'string', format: 'url' }\n    }\n  }\n});\n\n// Create with validation\nawait db.create('user1', userData, {\n  validate: true,\n  schemaName: 'users',\n  strict: true\n});\n```\n\n##  Batch Operations\n\nEfficient batch processing with ACID guarantees:\n\n```javascript\n// Batch write\nawait db.batchWrite([\n  { key: 'product1', data: { name: 'Laptop', price: 999.99 } },\n  { key: 'product2', data: { name: 'Mouse', price: 29.99 } },\n  { key: 'product3', data: { name: 'Keyboard', price: 79.99 } }\n]);\n\n// Batch read\nconst products = await db.batchRead(['product1', 'product2', 'product3']);\n```\n\n##  Cloud Backup\n\nConfigure automatic cloud backups:\n\n```javascript\ndb.configureBackup({\n  format: 'archive',\n  cloudStorage: {\n    provider: 'aws-s3',\n    region: 'us-east-1',\n    bucket: 'my-backup-bucket',\n    accessKeyId: process.env.AWS_ACCESS_KEY_ID,\n    secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY\n  },\n  retention: '30d'\n});\n\n// Perform backup\nconst result = await db.performBackup();\n```\n\n##  Data Recovery\n\nAutomatic crash recovery and cloud restore:\n\n```javascript\n// Configure data recovery\ndb.configureDataRecovery({\n  cloudStorage: cloudConfig,\n  localPath: './mydata'\n});\n\n// Recover specific file\nawait db.recoverFromCloud('important-data');\n\n// Recover all files\nconst result = await db.recoverAllFromCloud();\n```\n\n##  Monitoring\n\nBuilt-in performance monitoring and health checks:\n\n```javascript\n// Cache performance\nconst cacheStats = db.getCacheStats();\nconsole.log(`Cache hit rate: ${cacheStats.hitRate}%`);\n\n// Data integrity check\nconst integrity = await db.verifyDataIntegrity();\nif (!integrity.healthy) {\n  console.log(`Issues found: ${integrity.corruptedFiles.length} corrupted files`);\n}\n\n// Active transactions\nconst activeTx = db.getActiveTransactions();\nconsole.log(`Active transactions: ${activeTx.length}`);\n```\n\n##  Error Handling\n\nComprehensive error handling with detailed messages:\n\n```javascript\ntry {\n  await db.create('user', invalidData, { validate: true, strict: true });\n} catch (error) {\n  if (error.message.includes('Schema validation failed')) {\n    // Handle validation error\n  } else if (error.message.includes('already exists')) {\n    // Handle duplicate key error\n  }\n}\n```\n\n##  Configuration\n\n### Database Options\n```javascript\nconst db = new Tero({\n  directory: './data',     // Database directory\n  cacheSize: 1000         // Maximum cache entries\n});\n```\n\n### Schema Field Types\n- `string`: Text data with length and format validation\n- `number`: Numeric data with range validation\n- `boolean`: True/false values\n- `object`: Nested objects with property schemas\n- `array`: Arrays with item type validation\n- `date`: Date/time values\n- `any`: Any data type (no validation)\n\n### Schema Validation Options\n- `required`: Field is mandatory\n- `min/max`: Length/value constraints\n- `format`: Built-in formats (email, url, uuid, etc.)\n- `pattern`: Regular expression validation\n- `enum`: Allowed values list\n- `default`: Default value if not provided\n- `custom`: Custom validation function\n\n### Optimization Tips\n1. Use batch operations for multiple documents\n2. Enable caching for frequently accessed data\n3. Use schema validation to catch errors early\n4. Monitor cache hit rates and adjust cache size\n5. Use transactions for related operations\n\n##  Security\n\n- **Path Traversal Protection**: Automatic key sanitization\n- **Input Validation**: Comprehensive data validation\n- **Error Handling**: No sensitive data in error messages\n- **Access Control**: File system permissions respected\n\n## API Reference\n\n### Core Methods\n- `create(key, data, options?)`: Create new document\n- `get(key)`: Read document\n- `update(key, data, options?)`: Update document\n- `remove(key)`: Delete document\n- `exists(key)`: Check if document exists\n\n### Transaction Methods\n- `beginTransaction()`: Start new transaction\n- `write(txId, key, data, options?)`: Write in transaction\n- `read(txId, key)`: Read in transaction\n- `delete(txId, key)`: Delete in transaction\n- `commit(txId)`: Commit transaction\n- `rollback(txId)`: Rollback transaction\n\n### Batch Methods\n- `batchWrite(operations, options?)`: Batch write operations\n- `batchRead(keys)`: Batch read operations\n\n### Schema Methods\n- `setSchema(name, schema)`: Define schema\n- `getSchema(name)`: Get schema definition\n- `removeSchema(name)`: Remove schema\n- `validateData(name, data)`: Validate against schema\n\n### Utility Methods\n- `getCacheStats()`: Cache performance metrics\n- `verifyDataIntegrity()`: Check data health\n- `getActiveTransactions()`: List active transactions\n- `forceCheckpoint()`: Force WAL flush\n- `clearCache()`: Clear memory cache\n- `destroy()`: Cleanup and shutdown\n\n## Testing\n\nRun the production test suite:\n\n```bash\nnpm run test:production\n```\n\n## License\n\nMIT License - see LICENSE file for details.\n\n##  Contributing\n\n1. Fork the repository\n2. Create a feature branch\n3. Add tests for new functionality\n4. Ensure all tests pass\n5. Submit a pull request\n\n##  Support\n\nFor issues and questions:\n- GitHub Issues: [Report bugs and request features](https://github.com/codedynasty-dev/tero/issues)\n- Documentation: [Full API documentation](https://github.com/codedynasty-dev/tero/wiki)\n\n---\n\n**Tero** - Production-ready ACID JSON database for modern applications.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodedynasty-dev%2Ftero","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodedynasty-dev%2Ftero","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodedynasty-dev%2Ftero/lists"}