TypeORM (@banana-universe/plugin-typeorm)
Official plugin: registers a TypeORM DataSource, supports @InjectRepository(Entity) (constructor parameter metadata with explicit indices — no emitDecoratorMetadata), and @Transactional() with AsyncLocalStorage-scoped query runners.
Install
bash
npm install @banana-universe/plugin-typeorm typeorm reflect-metadata
# driver, e.g.
npm install pgUsage
Build a BananaPlugin with TypeOrmPlugin(options) where options is the TypeORM DataSource constructor options (entities, migrations, etc.).
typescript
import { BananaApp, defineBananaControllers } from '@banana-universe/bananajs'
import { TypeOrmPlugin } from '@banana-universe/plugin-typeorm'
await BananaApp.create({
controllers: defineBananaControllers(UserController),
plugins: [
TypeOrmPlugin({
type: 'postgres',
url: process.env.DATABASE_URL,
entities: [UserEntity],
synchronize: process.env.NODE_ENV !== 'production',
}),
],
})Features
TypeOrmPlugin— lazy-importstypeorm, constructsDataSource,initialize(), stores module-level reference for@Transactional@InjectRepository(Entity)— removed in v0.6+ (legacy DI). InjectDataSourcewith@inject('dataSource')(registered byTypeOrmPlugin) and callgetRepository(Entity)in the constructor or use a tsyringe factory provider@Transactional()— wraps method inQueryRunnertransaction; requires plugin registeredTransactionContext.getRunner()— access active runner inside transactional methodsonShutdown— destroys DataSource
Peer dependencies
typeorm— required at runtimetsyringe— provided by@banana-universe/bananajs;TypeOrmPluginusesregisterInstance('dataSource', dataSource)on the app root container
Domain repositories
TypeOrmRepositoryAdapter and TypeOrmUnitOfWork bridge @banana-universe/ddd repository contracts to TypeORM—see Layered architecture and packages/plugin-typeorm.