{"_id":"@10xsai/ts-serverless","_rev":"2-d2f800e3334099ae234b362736d7fd4f","name":"@10xsai/ts-serverless","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@10xsai/ts-serverless","version":"0.1.0","keywords":["typescript","drizzle","orm","cloudflare-workers","enterprise","framework","database","serverless","edge-runtime"],"author":{"url":"Sai Krishna Gottipalli","name":"10xsai"},"license":"MIT","_id":"@10xsai/ts-serverless@0.1.0","maintainers":[{"name":"10xsai","email":"10xsai.official@gmail.com"}],"homepage":"https://github.com/10xsai/ts-serverless#readme","bugs":{"url":"https://github.com/10xsai/ts-serverless/issues"},"dist":{"shasum":"c51af7ce168e46aa9bc9cf3af02e5a8b120b6bdc","tarball":"https://registry.npmjs.org/@10xsai/ts-serverless/-/ts-serverless-0.1.0.tgz","fileCount":73,"integrity":"sha512-hkt9x596mMJUlL44k4JokENDABzDO5Nr+467eFz0op1eRG3GubYzpG8f6Z1nXAXtxV/gYD+f9AioJP21/zxrAA==","signatures":[{"sig":"MEQCIB7HVjMjLaq61lA8CzE6GBrLfjghQThnDynRAsbITGTaAiBis9wQryfYCG2My1IJjwllndYOe8Yf9fNUXBELII9KXg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":148172},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","default":"./dist/index.js","development":"./src/index.ts"},"./package.json":"./package.json"},"gitHead":"a15246933bb320fc7669b13c7433a2fc44614219","scripts":{"dev":"tsc --watch","build":"tsc","start":"node dist/index.js","prepare":"npm run build"},"_npmUser":{"name":"10xsai","actor":{"name":"10xsai","type":"user","email":"10xsai.official@gmail.com"},"email":"10xsai.official@gmail.com"},"repository":{"url":"git+https://github.com/10xsai/ts-serverless.git","type":"git"},"_npmVersion":"10.9.2","description":"Enterprise-grade core framework built with TypeScript and Drizzle ORM, optimized for Cloudflare Workers and serverless environments","directories":{},"_nodeVersion":"22.16.0","dependencies":{"zod":"^3.22.4","tslib":"^2.3.0","nanoid":"^5.0.4","drizzle-orm":"^0.44.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.8.3","@types/node":"^24.0.3","drizzle-kit":"^0.31.1","@cloudflare/workers-types":"^4.20250620.0"},"_npmOperationalInternal":{"tmp":"tmp/ts-serverless_0.1.0_1750759084358_0.6882209555320522","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@10xsai/ts-serverless","version":"0.1.1","type":"module","main":"./dist/index.js","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{"./package.json":"./package.json",".":{"development":"./src/index.ts","types":"./dist/index.d.ts","import":"./dist/index.js","default":"./dist/index.js"}},"scripts":{"build":"tsc","dev":"tsc --watch","start":"node dist/index.js","prepare":"npm run build"},"dependencies":{"drizzle-orm":"^0.44.2","nanoid":"^5.0.4","tslib":"^2.3.0","zod":"^3.22.4"},"devDependencies":{"@cloudflare/workers-types":"^4.20250620.0","@types/node":"^24.0.3","drizzle-kit":"^0.31.1","typescript":"^5.8.3"},"keywords":["typescript","drizzle","orm","cloudflare-workers","enterprise","framework","database","serverless","edge-runtime"],"description":"Enterprise-grade core framework built with TypeScript and Drizzle ORM, optimized for Cloudflare Workers and serverless environments","author":{"name":"10xsai","url":"Sai Krishna Gottipalli"},"license":"MIT","homepage":"https://github.com/10xsai/ts-serverless#readme","repository":{"type":"git","url":"git+https://github.com/10xsai/ts-serverless.git"},"bugs":{"url":"https://github.com/10xsai/ts-serverless/issues"},"engines":{"node":">=18.0.0"},"publishConfig":{"access":"public"},"_id":"@10xsai/ts-serverless@0.1.1","gitHead":"794d82191dfdc976fb7e2e3ddd418b9b060b2520","_nodeVersion":"22.16.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-MHuMg0XAzPuYPwK7YWeBhvcexBNGMvmMaliSNcW9SKSudVtxJkvo0d7CnuQ24xaukRgo25bXpFsT4Ny9JJ01cw==","shasum":"04baf80c8813e5980ab14480f9eb47deb4930fc2","tarball":"https://registry.npmjs.org/@10xsai/ts-serverless/-/ts-serverless-0.1.1.tgz","fileCount":73,"unpackedSize":148172,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCICzQanLCRo1ZUwtPnPtMUpsOpOd/Tf3FA9cO+Jgy1tHuAiEA6ltNzUoxVYQsmFMV9zBUsrrGO2uL5MYxaxHnlG9zf6I="}]},"_npmUser":{"name":"10xsai","email":"10xsai.official@gmail.com","actor":{"name":"10xsai","email":"10xsai.official@gmail.com","type":"user"}},"directories":{},"maintainers":[{"name":"10xsai","email":"10xsai.official@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/ts-serverless_0.1.1_1750759252271_0.9103315555929401"},"_hasShrinkwrap":false}},"time":{"created":"2025-06-24T09:58:04.283Z","modified":"2025-06-24T10:00:52.659Z","0.1.0":"2025-06-24T09:58:04.533Z","0.1.1":"2025-06-24T10:00:52.471Z"},"bugs":{"url":"https://github.com/10xsai/ts-serverless/issues"},"author":{"name":"10xsai","url":"Sai Krishna Gottipalli"},"license":"MIT","homepage":"https://github.com/10xsai/ts-serverless#readme","keywords":["typescript","drizzle","orm","cloudflare-workers","enterprise","framework","database","serverless","edge-runtime"],"repository":{"type":"git","url":"git+https://github.com/10xsai/ts-serverless.git"},"description":"Enterprise-grade core framework built with TypeScript and Drizzle ORM, optimized for Cloudflare Workers and serverless environments","maintainers":[{"name":"10xsai","email":"10xsai.official@gmail.com"}],"readme":"# @10xsai/ts-serverless\n\n[![TypeScript](https://img.shields.io/badge/TypeScript-5.0+-blue.svg)](https://www.typescriptlang.org/)\n[![Cloudflare Workers](https://img.shields.io/badge/Cloudflare-Workers-orange.svg)](https://workers.cloudflare.com/)\n[![Drizzle ORM](https://img.shields.io/badge/Drizzle-ORM-green.svg)](https://orm.drizzle.team/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n> **Enterprise-grade TypeScript framework built for Cloudflare Workers and serverless environments**\n\n`@10xsai/ts-serverless` is a comprehensive, lightweight framework designed specifically for building robust, scalable applications in serverless environments. Built with TypeScript, Drizzle ORM, and optimized for Cloudflare Workers, it provides enterprise-grade patterns while maintaining optimal performance for edge computing.\n\n## ✨ **Key Features**\n\n- 🚀 **Serverless-First**: Optimized for Cloudflare Workers and edge environments\n- 🔒 **Type-Safe**: Full TypeScript support with branded types and strict typing\n- 🗄️ **Database Agnostic**: Built-in support for Drizzle ORM with multiple database adapters\n- 🛡️ **Security Built-in**: Input sanitization, validation, and security utilities\n- 📦 **Tree-Shakeable**: Modular architecture with optimal bundle sizes\n- 🏗️ **Enterprise Patterns**: Repository, Service, and Entity abstractions\n- 🔧 **Developer Experience**: Comprehensive error handling and debugging tools\n- 📚 **Fully Documented**: Complete JSDoc coverage and extensive examples\n\n## 🚀 **Quick Start**\n\n### Installation\n\n```bash\nnpm install @10xsai/ts-serverless\n# or\npnpm add @10xsai/ts-serverless\n# or\nyarn add @10xsai/ts-serverless\n```\n\n### Basic Usage\n\n```typescript\nimport {\n  Entity,\n  BaseRepository,\n  BaseService,\n  createApiResponse,\n} from \"@10xsai/ts-serverless\";\n\n// Define your entity\nclass User extends Entity {\n  email: string;\n  name: string;\n\n  constructor(data: { email: string; name: string }) {\n    super();\n    this.email = data.email;\n    this.name = data.name;\n  }\n}\n\n// Create repository\nclass UserRepository extends BaseRepository<User> {\n  protected async executeCreate(data: CreateUserInput): Promise<User> {\n    // Implementation with your database\n    return new User(data);\n  }\n\n  // ... other methods\n}\n\n// Create service\nclass UserService extends BaseService<User> {\n  constructor(repository: UserRepository) {\n    super(repository);\n  }\n\n  async createUser(data: CreateUserInput): Promise<User> {\n    return await this.create(data);\n  }\n}\n\n// Use in Cloudflare Worker\nexport default {\n  async fetch(request: Request): Promise<Response> {\n    try {\n      const userService = new UserService(new UserRepository());\n      const user = await userService.createUser({\n        email: \"user@example.com\",\n        name: \"John Doe\",\n      });\n\n      return createApiResponse.success(user);\n    } catch (error) {\n      return createApiResponse.error(error);\n    }\n  },\n};\n```\n\n## 📚 **Documentation**\n\n### 🎯 **Getting Started**\n\n- [Installation & Setup](./docs/getting-started.md)\n- [Your First Application](./docs/getting-started.md#your-first-application)\n- [Cloudflare Workers Integration](./docs/guides/cloudflare-workers.md)\n\n### 🏗️ **Core Concepts**\n\n- [Architecture Overview](./docs/architecture.md)\n- [Entity System](./docs/modules/base-entities.md)\n- [Repository Pattern](./docs/modules/repositories.md)\n- [Service Layer](./docs/modules/services.md)\n- [Error Handling](./docs/modules/error-handling.md)\n\n### 🔧 **Advanced Features**\n\n- [Query System](./docs/modules/query-system.md)\n- [Validation Framework](./docs/modules/validation.md)\n- [Security Utilities](./docs/modules/security.md)\n- [Database Management](./docs/modules/database.md)\n\n### 📖 **Guides**\n\n- [Best Practices](./docs/guides/best-practices.md)\n- [Migration from core-service](./docs/guides/migration-from-core-service.md)\n- [Testing Strategies](./docs/guides/testing.md)\n- [Deployment Guide](./docs/guides/deployment.md)\n\n### 🎨 **Examples**\n\n- [Basic CRUD Application](./examples/basic-usage/)\n- [User Management System](./examples/user-management/)\n- [E-commerce API](./examples/e-commerce/)\n- [Cloudflare Worker with D1](./examples/cloudflare-worker/)\n\n## 🏗️ **Architecture**\n\n```mermaid\ngraph TB\n    A[Application Layer] --> B[Service Layer]\n    B --> C[Repository Layer]\n    C --> D[Entity Layer]\n\n    B --> E[Validation]\n    B --> F[Error Handling]\n    B --> G[Security]\n\n    C --> H[Query System]\n    C --> I[Database]\n\n    J[Utilities] --> A\n    J --> B\n    J --> C\n```\n\n### **Core Modules**\n\n| Module         | Description                               | Key Features                                    |\n| -------------- | ----------------------------------------- | ----------------------------------------------- |\n| **Base**       | Entity, Repository, Service abstractions  | Audit trails, soft delete, validation hooks     |\n| **Database**   | Connection management, migrations, schema | D1 adapter, connection pooling, schema builder  |\n| **Validation** | Zod-based validation framework            | Context-aware validation, custom rules          |\n| **Errors**     | Comprehensive error handling              | Typed errors, severity levels, context          |\n| **Query**      | Advanced query building                   | Fluent API, pagination, filtering               |\n| **Security**   | Security utilities                        | Sanitization, XSS protection, validation        |\n| **Utils**      | Helper functions and utilities            | ID generation, date handling, response creators |\n\n## 🔧 **API Reference**\n\n### **Core Classes**\n\n#### **Entity**\n\n```typescript\nabstract class Entity {\n  id: EntityId;\n  createdAt: Date;\n  updatedAt: Date;\n  deletedAt?: Date;\n  version: number;\n\n  // Methods\n  markAsDeleted(): void;\n  updateVersion(): void;\n  getAuditInfo(): AuditInfo;\n}\n```\n\n#### **BaseRepository**\n\n```typescript\nabstract class BaseRepository<T extends BaseEntity> {\n  // CRUD Operations\n  async create(data: CreateInput): Promise<T>;\n  async findById(id: EntityId): Promise<T | null>;\n  async findMany(criteria: FilterCriteria): Promise<T[]>;\n  async update(id: EntityId, data: UpdateInput): Promise<T>;\n  async delete(id: EntityId): Promise<void>;\n\n  // Advanced Operations\n  async list(options: ListOptions): Promise<PaginatedResult<T>>;\n  async search(query: SearchQuery): Promise<SearchResult<T>>;\n  async count(criteria?: FilterCriteria): Promise<number>;\n  async exists(id: EntityId): Promise<boolean>;\n}\n```\n\n#### **BaseService**\n\n```typescript\nabstract class BaseService<T extends BaseEntity> {\n  // Business Logic Layer\n  async create(data: CreateInput): Promise<T>;\n  async getById(id: EntityId): Promise<T>;\n  async update(id: EntityId, data: UpdateInput): Promise<T>;\n  async delete(id: EntityId): Promise<void>;\n\n  // Validation Hooks\n  protected async validateCreate(data: CreateInput): Promise<void>;\n  protected async validateUpdate(\n    id: EntityId,\n    data: UpdateInput\n  ): Promise<void>;\n}\n```\n\n### **Utility Functions**\n\n#### **Response Creators**\n\n```typescript\n// Success responses\ncreateApiResponse.success(data);\ncreateApiResponse.created(data);\ncreateApiResponse.paginated(data, pagination);\n\n// Error responses\ncreateApiResponse.error(error);\ncreateApiResponse.notFound(message);\ncreateApiResponse.validation(errors);\n```\n\n#### **Query Builders**\n\n```typescript\n// Filter builder\nconst filter = createFilter()\n  .eq(\"status\", \"active\")\n  .gt(\"createdAt\", new Date(\"2024-01-01\"))\n  .build();\n\n// Query builder\nconst query = createQueryBuilder<User>()\n  .where(filter)\n  .orderBy([{ field: \"createdAt\", direction: \"desc\" }])\n  .limit(10)\n  .build();\n```\n\n## 🛡️ **Security**\n\nThe framework includes built-in security features:\n\n- **Input Sanitization**: Automatic HTML, SQL, and XSS protection\n- **Validation**: Zod-based validation with security rules\n- **Type Safety**: Branded types prevent common security issues\n- **Audit Logging**: Built-in audit trails for compliance\n\n```typescript\nimport { sanitizeInput, validateSecure } from \"@10xsai/ts-serverless\";\n\n// Sanitize user input\nconst cleanInput = sanitizeInput.html(userInput);\n\n// Validate for security issues\nconst isSecure = validateSecure.checkSqlInjection(query);\n```\n\n## 📊 **Performance**\n\nOptimized for serverless environments:\n\n- **Cold Start**: < 10ms initialization time\n- **Bundle Size**: Tree-shakeable, import only what you need\n- **Memory Usage**: Minimal memory footprint\n- **Edge Ready**: Zero Node.js dependencies\n\n## 🤝 **Contributing**\n\nWe welcome contributions! Please see our [Contributing Guide](./CONTRIBUTING.md) for details.\n\n### **Development Setup**\n\n```bash\n# Clone the repository\ngit clone https://github.com/10xsai/10xsai.com.git\ncd 10xsai.com\n\n# Install dependencies\npnpm install\n\n# Run tests\nnx test @10xsai/ts-serverless\n\n# Build the package\nnx build @10xsai/ts-serverless\n```\n\n## 📝 **License**\n\nMIT License - see the [LICENSE](./LICENSE) file for details.\n\n## 🆘 **Support**\n\n- 📖 **Documentation**: [Full documentation](./docs/)\n- 💬 **Issues**: [GitHub Issues](https://github.com/10xsai/10xsai.com/issues)\n- 🗨️ **Discussions**: [GitHub Discussions](https://github.com/10xsai/10xsai.com/discussions)\n\n## 🗺️ **Roadmap**\n\n- [ ] Additional database adapters (PostgreSQL, MySQL)\n- [ ] Advanced caching strategies\n- [ ] Real-time subscriptions\n- [ ] GraphQL integration\n- [ ] Monitoring and observability tools\n\n---\n\n**Built with ❤️ by the 10XSAI**\n","readmeFilename":"README.md"}