How asheswook/tranjs works
Project type and purpose
• TranJS is a TypeScript-native, monorepo-based framework (managed by Lerna) that provides declarative transaction management for Node.js, without relying on ORMs.
• It consists of a core library plus pluggable drivers (e.g., mysql2, pg) that implement database-specific context and management.
File structure
• Top-level folders:
• packages/core – the heart of the framework (decorators, transaction manager, context propagation)
• packages/mysql2 and packages/pg – driver packages that bind core functionality to specific DB clients
• docs – API and implementation guides
• examples – minimal service code showing usage with each driver
• Configuration files: lerna.json (monorepo), tsconfig.json (shared), individual tsconfig.json and package.json in each package
• Tests live under packages/core/test, verifying core behavior (decorators, manager, async local storage)
README for additional insights
• Purpose: enable @Transactional decorator, manage commit/rollback automatically
• Features: no external dependencies, uses TypeScript decorators, leverages AsyncLocalStorage for context propagation
• Usage: user service classes call ctx().execute(…) under a transactional boundary
Detail without overthinking
• Sub-component of core (decorator.ts, manager.ts, asyncLocal.ts, context.ts) if needed
• Driver modules separately to illustrate the pluggable architecture
• Path of transaction context from entry (decorator) through to commit/rollback