Initial commit - Event Planner application
This commit is contained in:
21
node_modules/@mikro-orm/nestjs/LICENSE
generated
vendored
Normal file
21
node_modules/@mikro-orm/nestjs/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 Dario Mancuso, Martin Adámek
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
503
node_modules/@mikro-orm/nestjs/README.md
generated
vendored
Normal file
503
node_modules/@mikro-orm/nestjs/README.md
generated
vendored
Normal file
@@ -0,0 +1,503 @@
|
||||
<p align="center" style="vertical-align:middle">
|
||||
<a href="https://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo_text.svg" width="200" alt="Nest Logo" /></a><br /><a href="https://mikro-orm.io/" target="blank"><img src="https://raw.githubusercontent.com/mikro-orm/mikro-orm/master/docs/static/img/logo-readme.svg?sanitize=true" width="200" alt="MikroORM"></a>
|
||||
</p>
|
||||
|
||||
> Based on [dario1985/nestjs-mikro-orm](https://github.com/dario1985/nestjs-mikro-orm).
|
||||
|
||||
[](https://www.npmjs.com/package/@mikro-orm/nestjs)
|
||||
[](https://join.slack.com/t/mikroorm/shared_invite/enQtNTM1ODYzMzM4MDk3LWM4ZDExMjU5ZDhmNjA2MmM3MWMwZmExNjhhNDdiYTMwNWM0MGY5ZTE3ZjkyZTMzOWExNDgyYmMzNDE1NDI5NjA)
|
||||
[](https://www.npmjs.com/package/@mikro-orm/nestjs)
|
||||
[](https://github.com/mikro-orm/nestjs/actions?workflow=tests)
|
||||
|
||||
## Description
|
||||
|
||||
The [MikroORM](https://github.com/mikro-orm/mikro-orm) module for [NestJS](https://github.com/nestjs/nest).
|
||||
|
||||
## 🚀 Quick Start
|
||||
|
||||
First install the module via `yarn` or `npm` and do not forget to install the database driver as well:
|
||||
|
||||
```bash
|
||||
$ yarn add @mikro-orm/core @mikro-orm/nestjs @mikro-orm/mongodb # for mongo
|
||||
$ yarn add @mikro-orm/core @mikro-orm/nestjs @mikro-orm/mysql # for mysql/mariadb
|
||||
$ yarn add @mikro-orm/core @mikro-orm/nestjs @mikro-orm/mariadb # for mysql/mariadb
|
||||
$ yarn add @mikro-orm/core @mikro-orm/nestjs @mikro-orm/postgresql # for postgresql
|
||||
$ yarn add @mikro-orm/core @mikro-orm/nestjs @mikro-orm/sqlite # for sqlite
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```bash
|
||||
$ npm i -s @mikro-orm/core @mikro-orm/nestjs @mikro-orm/mongodb # for mongo
|
||||
$ npm i -s @mikro-orm/core @mikro-orm/nestjs @mikro-orm/mysql # for mysql/mariadb
|
||||
$ npm i -s @mikro-orm/core @mikro-orm/nestjs @mikro-orm/mariadb # for mysql/mariadb
|
||||
$ npm i -s @mikro-orm/core @mikro-orm/nestjs @mikro-orm/postgresql # for postgresql
|
||||
$ npm i -s @mikro-orm/core @mikro-orm/nestjs @mikro-orm/sqlite # for sqlite
|
||||
```
|
||||
|
||||
Once the installation process is completed, we can import the `MikroOrmModule` into the root `AppModule`.
|
||||
|
||||
```typescript
|
||||
@Module({
|
||||
imports: [
|
||||
MikroOrmModule.forRoot({
|
||||
entities: ['../dist/entities'],
|
||||
entitiesTs: ['../src/entities'],
|
||||
dbName: 'my-db-name.sqlite3',
|
||||
type: 'sqlite',
|
||||
baseDir: __dirname,
|
||||
}),
|
||||
],
|
||||
controllers: [AppController],
|
||||
providers: [AppService],
|
||||
})
|
||||
export class AppModule {}
|
||||
```
|
||||
|
||||
The `forRoot()` method accepts the same configuration object as `init()` from the MikroORM package.
|
||||
You can also omit the parameter to use the CLI config.
|
||||
|
||||
Afterward, the `EntityManager` will be available to inject across entire project (without importing any module elsewhere).
|
||||
|
||||
```ts
|
||||
@Injectable()
|
||||
export class MyService {
|
||||
|
||||
constructor(private readonly orm: MikroORM,
|
||||
private readonly em: EntityManager) { }
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
To define which repositories shall be registered in the current scope you can use the `forFeature()` method. For example, in this way:
|
||||
|
||||
> You should **not** register your base entities via `forFeature()`, as there are no
|
||||
> repositories for those. On the other hand, base entities need to be part of the list
|
||||
> in `forRoot()` (or in the ORM config in general).
|
||||
|
||||
```typescript
|
||||
// photo.module.ts
|
||||
|
||||
@Module({
|
||||
imports: [MikroOrmModule.forFeature([Photo])],
|
||||
providers: [PhotoService],
|
||||
controllers: [PhotoController],
|
||||
})
|
||||
export class PhotoModule {}
|
||||
```
|
||||
|
||||
and import it into the root `AppModule`:
|
||||
|
||||
```typescript
|
||||
// app.module.ts
|
||||
@Module({
|
||||
imports: [MikroOrmModule.forRoot(...), PhotoModule],
|
||||
})
|
||||
export class AppModule {}
|
||||
```
|
||||
|
||||
In this way we can inject the `PhotoRepository` to the `PhotoService` using the `@InjectRepository()` decorator:
|
||||
|
||||
```typescript
|
||||
@Injectable()
|
||||
export class PhotoService {
|
||||
constructor(
|
||||
@InjectRepository(Photo)
|
||||
private readonly photoRepository: EntityRepository<Photo>
|
||||
) {}
|
||||
|
||||
// ...
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
## Driver-specific imports
|
||||
|
||||
When you try to inject the `EntityManager` or `MikroORM` symbols exported from the driver package, Nest.js needs to be aware of those typed. In other words, those driver specific exports need to be specifically registered in the DI container. This module uses automated discovery of the driver type in order to do that, but it fails to work when you use `useFactory` which requires some dependencies.
|
||||
|
||||
Instead of relying on this discovery, you can provide the driver type explicitly:
|
||||
|
||||
```typescript
|
||||
@Module({
|
||||
imports: [
|
||||
MikroOrmModule.forRootAsync({
|
||||
useFactory: (configService: ConfigService) => configService.getOrThrow(ConfigKey.ORM),
|
||||
inject: [ConfigService],
|
||||
driver: PostgreSqlDriver,
|
||||
}),
|
||||
],
|
||||
controllers: [AppController],
|
||||
providers: [AppService],
|
||||
})
|
||||
export class AppModule {}
|
||||
```
|
||||
|
||||
## Load entities automatically
|
||||
|
||||
Manually adding entities to the entities array of the connection options can be
|
||||
tedious. In addition, referencing entities from the root module breaks application
|
||||
domain boundaries and causes leaking implementation details to other parts of the
|
||||
application. To solve this issue, static glob paths can be used.
|
||||
|
||||
Note, however, that glob paths are not supported by webpack, so if you are building
|
||||
your application within a monorepo, you won't be able to use them. To address this
|
||||
issue, an alternative solution is provided. To automatically load entities, set the
|
||||
`autoLoadEntities` property of the configuration object (passed into the `forRoot()`
|
||||
method) to `true`, as shown below:
|
||||
|
||||
```ts
|
||||
@Module({
|
||||
imports: [
|
||||
MikroOrmModule.forRoot({
|
||||
...
|
||||
autoLoadEntities: true,
|
||||
}),
|
||||
],
|
||||
})
|
||||
export class AppModule {}
|
||||
```
|
||||
|
||||
With that option specified, every entity registered through the `forFeature()`
|
||||
method will be automatically added to the entities array of the configuration
|
||||
object.
|
||||
|
||||
> Note that entities that aren't registered through the `forFeature()` method, but
|
||||
> are only referenced from the entity (via a relationship), won't be included by
|
||||
> way of the `autoLoadEntities` setting.
|
||||
|
||||
> Using `autoLoadEntities` also has no effect on the MikroORM CLI - for that we
|
||||
> still need CLI config with the full list of entities. On the other hand, we can
|
||||
> use globs there, as the CLI won't go thru webpack.
|
||||
|
||||
## Request scoped handlers in queues
|
||||
|
||||
As mentioned in the docs, we need a clean state for each request. That is handled
|
||||
automatically thanks to the `RequestContext` helper registered via middleware.
|
||||
|
||||
But middlewares are executed only for regular HTTP request handles, what if we need
|
||||
a request scoped method outside of that? One example of that is queue handlers or
|
||||
scheduled tasks.
|
||||
|
||||
We can use the `@CreateRequestContext()` decorator. It requires you to first inject the
|
||||
`MikroORM` instance to current context, it will be then used to create the context
|
||||
for you. Under the hood, the decorator will register new request context for your
|
||||
method and execute it inside the context.
|
||||
|
||||
```ts
|
||||
@Injectable()
|
||||
export class MyService {
|
||||
|
||||
constructor(private readonly orm: MikroORM) { }
|
||||
|
||||
@CreateRequestContext()
|
||||
async doSomething() {
|
||||
// this will be executed in a separate context
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
## Serialization caveat
|
||||
|
||||
[NestJS built-in serialization](https://docs.nestjs.com/techniques/serialization) relies on [class-transformer](https://github.com/typestack/class-transformer). Since MikroORM wraps every single entity relation in a `Reference` or a `Collection` instance (for type-safety), this will make the built-in `ClassSerializerInterceptor` blind to any wrapped relations. In other words, if you return MikroORM entities from your HTTP or WebSocket handlers, all of their relations will NOT be serialized.
|
||||
|
||||
Luckily, MikroORM provides a [serialization API](https://mikro-orm.io/docs/serializing) which can be used in lieu of `ClassSerializerInterceptor`.
|
||||
|
||||
```typescript
|
||||
@Entity()
|
||||
export class Book {
|
||||
|
||||
@Property({ hidden: true }) // --> Equivalent of class-transformer's `@Exclude`
|
||||
hiddenField: number = Date.now();
|
||||
|
||||
@Property({ persist: false }) // --> Will only exist in memory (and will be serialized). Similar to class-transformer's `@Expose()`
|
||||
count?: number;
|
||||
|
||||
@ManyToOne({ serializer: value => value.name, serializedName: 'authorName' }) // Equivalent of class-transformer's `@Transform()`
|
||||
author: Author;
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Using `AsyncLocalStorage` for request context
|
||||
|
||||
> Since v5 AsyncLocalStorage is used inside RequestContext helper so this section is no longer valid.
|
||||
|
||||
By default, the `domain` api is used in the `RequestContext` helper. Since `@mikro-orm/core@4.0.3`,
|
||||
you can use the new `AsyncLocalStorage` too, if you are on up to date node version:
|
||||
|
||||
```typescript
|
||||
// create new (global) storage instance
|
||||
const storage = new AsyncLocalStorage<EntityManager>();
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
MikroOrmModule.forRoot({
|
||||
// ...
|
||||
registerRequestContext: false, // disable automatatic middleware
|
||||
context: () => storage.getStore(), // use our AsyncLocalStorage instance
|
||||
}),
|
||||
],
|
||||
controllers: [AppController],
|
||||
providers: [AppService],
|
||||
})
|
||||
export class AppModule {}
|
||||
|
||||
// register the request context middleware
|
||||
const app = await NestFactory.create(AppModule, { ... });
|
||||
|
||||
app.use((req, res, next) => {
|
||||
storage.run(orm.em.fork(true, true), next);
|
||||
});
|
||||
```
|
||||
|
||||
## Using NestJS `Injection Scopes` for request context
|
||||
|
||||
Since `@nestjs/common@6`, you can use the new `Injection Scopes` (https://docs.nestjs.com/fundamentals/injection-scopes) too:
|
||||
|
||||
```typescript
|
||||
import { Scope } from '@nestjs/common';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
MikroOrmModule.forRoot({
|
||||
// ...
|
||||
registerRequestContext: false, // disable automatatic middleware
|
||||
scope: Scope.REQUEST
|
||||
}),
|
||||
],
|
||||
controllers: [AppController],
|
||||
providers: [AppService]
|
||||
})
|
||||
export class AppModule {}
|
||||
```
|
||||
|
||||
Or, if you're using the Async provider:
|
||||
|
||||
```typescript
|
||||
import { Scope } from '@nestjs/common';
|
||||
import { PostgreSqlDriver } from '@mikro-orm/postgresql';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
MikroOrmModule.forRootAsync({
|
||||
// ...
|
||||
useFactory: () => ({
|
||||
// ...
|
||||
registerRequestContext: false, // disable automatatic middleware
|
||||
}),
|
||||
scope: Scope.REQUEST
|
||||
})
|
||||
],
|
||||
controllers: [AppController],
|
||||
providers: [AppService]
|
||||
})
|
||||
export class AppModule {}
|
||||
```
|
||||
|
||||
> Please note that this might have some impact on performance,
|
||||
> see: https://docs.nestjs.com/fundamentals/injection-scopes#performance
|
||||
|
||||
## Using custom repositories
|
||||
|
||||
When using custom repositories, we can get around the need for `@InjectRepository()`
|
||||
decorator by naming our repositories the same way as `getRepositoryToken()` method do:
|
||||
|
||||
```ts
|
||||
export const getRepositoryToken = <T> (entity: EntityName<T>) => `${Utils.className(entity)}Repository`;
|
||||
```
|
||||
|
||||
In other words, as long as we name the repository same was as the entity is called,
|
||||
appending `Repository` suffix, the repository will be registered automatically in
|
||||
the Nest.js DI container.
|
||||
|
||||
`**./author.entity.ts**`
|
||||
|
||||
```ts
|
||||
@Entity({ customRepository: () => AuthorRepository })
|
||||
export class Author {
|
||||
|
||||
// to allow inference in `em.getRepository()`
|
||||
[EntityRepositoryType]?: AuthorRepository;
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
`**./author.repository.ts**`
|
||||
|
||||
```ts
|
||||
export class AuthorRepository extends EntityRepository<Author> {
|
||||
|
||||
// your custom methods...
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
As the custom repository name is the same as what `getRepositoryToken()` would
|
||||
return, we do not need the `@InjectRepository()` decorator anymore:
|
||||
|
||||
```ts
|
||||
@Injectable()
|
||||
export class MyService {
|
||||
|
||||
constructor(private readonly repo: AuthorRepository) { }
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
## App shutdown and cleanup
|
||||
|
||||
By default, NestJS does not listen for system process termination signals (for example SIGTERM). Because of this, the MikroORM shutdown logic will never executed if the process is terminated, which could lead to database connections remaining open and consuming resources. To enable this, the `enableShutdownHooks` function needs to be called when starting up the application.
|
||||
|
||||
```ts
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule);
|
||||
|
||||
// Starts listening for shutdown hooks
|
||||
app.enableShutdownHooks();
|
||||
|
||||
await app.listen(3000);
|
||||
}
|
||||
```
|
||||
|
||||
More information about [enableShutdownHooks](https://docs.nestjs.com/fundamentals/lifecycle-events#application-shutdown)
|
||||
|
||||
## Multiple Database Connections
|
||||
|
||||
You can define multiple database connections by registering multiple `MikroOrmModule`'s, each with a unique `contextName`. You will need to disable the automatic request context middleware by setting `registerRequestContext` to `false`, as it wouldn't work with this approach - note that this needs to be part of all your `MikroOrmModule`s with non-default `contextName`. To have the same automatic request context behaviour, you must register `MikroOrmModule` with `forMiddleware()` instead:
|
||||
|
||||
```typescript
|
||||
@Module({
|
||||
imports: [
|
||||
MikroOrmModule.forRoot({
|
||||
contextName: 'db1',
|
||||
registerRequestContext: false, // disable automatatic middleware
|
||||
...
|
||||
}),
|
||||
MikroOrmModule.forRoot({
|
||||
contextName: 'db2',
|
||||
registerRequestContext: false, // disable automatatic middleware
|
||||
...
|
||||
}),
|
||||
MikroOrmModule.forMiddleware()
|
||||
],
|
||||
controllers: [AppController],
|
||||
providers: [AppService],
|
||||
})
|
||||
export class AppModule {}
|
||||
```
|
||||
|
||||
Since MikroORM v6.4, you can also define [multiple configurations](https://mikro-orm.io/docs/quick-start#configuration-file-structure) as part of a single ORM config. If you want to use such a combined config file, you need to destructure the result, since it will be also an array:
|
||||
|
||||
```typescript
|
||||
@Module({
|
||||
imports: [
|
||||
// `config` exports an array of configs
|
||||
...MikroOrmModule.forRoot(config),
|
||||
MikroOrmModule.forMiddleware()
|
||||
],
|
||||
controllers: [AppController],
|
||||
providers: [AppService],
|
||||
})
|
||||
export class AppModule {}
|
||||
```
|
||||
|
||||
To access different `MikroORM`/`EntityManager` connections you have to use the new injection tokens `@InjectMikroORM()`/`@InjectEntityManager()` where you are required to pass the `contextName` in:
|
||||
|
||||
```ts
|
||||
@Injectable()
|
||||
export class MyService {
|
||||
|
||||
constructor(@InjectMikroORM('db1') private readonly orm1: MikroORM,
|
||||
@InjectMikroORM('db2') private readonly orm2: MikroORM,
|
||||
@InjectEntityManager('db1') private readonly em1: EntityManager,
|
||||
@InjectEntityManager('db2') private readonly em2: EntityManager) { }
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
When defining your repositories with `forFeature()` method you will need to set which `contextName` you want it registered against:
|
||||
|
||||
```typescript
|
||||
// photo.module.ts
|
||||
|
||||
@Module({
|
||||
imports: [MikroOrmModule.forFeature([Photo], 'db1')],
|
||||
providers: [PhotoService],
|
||||
controllers: [PhotoController],
|
||||
})
|
||||
export class PhotoModule {}
|
||||
```
|
||||
|
||||
When using the `@InjectRepository` decorator you will also need to pass the `contextName` you want to get it from:
|
||||
|
||||
```typescript
|
||||
@Injectable()
|
||||
export class PhotoService {
|
||||
constructor(
|
||||
@InjectRepository(Photo, 'db1')
|
||||
private readonly photoRepository: EntityRepository<Photo>
|
||||
) {}
|
||||
|
||||
// ...
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
You can use the `@InjectMikroORMs` decorator to get all registered MikroORM instances:
|
||||
|
||||
```typescript
|
||||
@Injectable()
|
||||
export class MyService {
|
||||
|
||||
constructor(@InjectMikroORMs() private readonly orms: MikroORM[]) { }
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
The `nestjs-mikro-orm` package exposes `getRepositoryToken()` function that returns prepared token based on a given entity to allow mocking the repository.
|
||||
|
||||
```typescript
|
||||
@Module({
|
||||
providers: [
|
||||
PhotoService,
|
||||
{
|
||||
provide: getRepositoryToken(Photo),
|
||||
useValue: mockedRepository,
|
||||
},
|
||||
],
|
||||
})
|
||||
export class PhotoModule {}
|
||||
```
|
||||
|
||||
## 🤝 Contributing
|
||||
|
||||
Contributions, issues and feature requests are welcome. Please read
|
||||
[CONTRIBUTING.md](CONTRIBUTING.md)
|
||||
for details on the process for submitting pull requests to us.
|
||||
|
||||
## Authors
|
||||
|
||||
👤 **Dario Mancuso**
|
||||
|
||||
- Github: [@dario1985](https://github.com/dario1985)
|
||||
|
||||
👤 **Martin Adámek**
|
||||
|
||||
- Twitter: [@B4nan](https://twitter.com/B4nan)
|
||||
- Github: [@b4nan](https://github.com/b4nan)
|
||||
|
||||
See also the list of contributors who [participated](https://github.com/mikro-orm/nestjs/contributors) in this project.
|
||||
|
||||
## Show Your Support
|
||||
|
||||
Please ⭐️ this repository if this project helped you!
|
||||
|
||||
## 📝 License
|
||||
|
||||
Copyright © 2018 [Martin Adámek](https://github.com/b4nan).
|
||||
|
||||
This project is licensed under the MIT License - see the [LICENSE file](LICENSE) for details.
|
||||
5
node_modules/@mikro-orm/nestjs/index.d.ts
generated
vendored
Normal file
5
node_modules/@mikro-orm/nestjs/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
export * from './mikro-orm.module.js';
|
||||
export * from './mikro-orm.common.js';
|
||||
export * from './mikro-orm.middleware.js';
|
||||
export * from './multiple-mikro-orm.middleware.js';
|
||||
export * from './typings.js';
|
||||
5
node_modules/@mikro-orm/nestjs/index.js
generated
vendored
Normal file
5
node_modules/@mikro-orm/nestjs/index.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
export * from './mikro-orm.module.js';
|
||||
export * from './mikro-orm.common.js';
|
||||
export * from './mikro-orm.middleware.js';
|
||||
export * from './multiple-mikro-orm.middleware.js';
|
||||
export * from './typings.js';
|
||||
3
node_modules/@mikro-orm/nestjs/middleware.helper.d.ts
generated
vendored
Normal file
3
node_modules/@mikro-orm/nestjs/middleware.helper.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { type MiddlewareConsumer } from '@nestjs/common';
|
||||
import type { MikroOrmMiddlewareModuleOptions } from './typings.js';
|
||||
export declare function forRoutesPath(options: MikroOrmMiddlewareModuleOptions, consumer: MiddlewareConsumer): string;
|
||||
17
node_modules/@mikro-orm/nestjs/middleware.helper.js
generated
vendored
Normal file
17
node_modules/@mikro-orm/nestjs/middleware.helper.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import { HttpStatus } from '@nestjs/common';
|
||||
export function forRoutesPath(options, consumer) {
|
||||
if (options.forRoutesPath) {
|
||||
return options.forRoutesPath;
|
||||
}
|
||||
// detect nest v11 based on a newly added enum value
|
||||
if (HttpStatus.MULTI_STATUS) {
|
||||
return '{*all}';
|
||||
}
|
||||
const isFastify = (consumer) => {
|
||||
if (typeof consumer.httpAdapter !== 'object') {
|
||||
return false;
|
||||
}
|
||||
return consumer.httpAdapter.constructor.name.toLowerCase().startsWith('fastify');
|
||||
};
|
||||
return isFastify(consumer) ? '(.*)' : '*';
|
||||
}
|
||||
19
node_modules/@mikro-orm/nestjs/mikro-orm-core.module.d.ts
generated
vendored
Normal file
19
node_modules/@mikro-orm/nestjs/mikro-orm-core.module.d.ts
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
import { type DynamicModule, type MiddlewareConsumer, type NestModule, type OnApplicationShutdown } from '@nestjs/common';
|
||||
import { ModuleRef } from '@nestjs/core';
|
||||
import type { MikroOrmModuleOptions, MikroOrmModuleAsyncOptions, MikroOrmModuleSyncOptions } from './typings.js';
|
||||
export declare class MikroOrmCoreModule implements NestModule, OnApplicationShutdown {
|
||||
private readonly options;
|
||||
private readonly moduleRef;
|
||||
constructor(options: MikroOrmModuleOptions, moduleRef: ModuleRef);
|
||||
static forRoot(options: MikroOrmModuleSyncOptions): Promise<DynamicModule>;
|
||||
static forRootAsync(options: MikroOrmModuleAsyncOptions): Promise<DynamicModule>;
|
||||
private static buildDynamicModule;
|
||||
/**
|
||||
* Tries to create the driver instance to use the actual entity manager implementation for DI symbol.
|
||||
* This helps with dependency resolution issues when importing the EM from driver package (e.g. `SqlEntityManager`).
|
||||
*/
|
||||
private static createEntityManager;
|
||||
onApplicationShutdown(): Promise<void>;
|
||||
configure(consumer: MiddlewareConsumer): void;
|
||||
private static setContextName;
|
||||
}
|
||||
144
node_modules/@mikro-orm/nestjs/mikro-orm-core.module.js
generated
vendored
Normal file
144
node_modules/@mikro-orm/nestjs/mikro-orm-core.module.js
generated
vendored
Normal file
@@ -0,0 +1,144 @@
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
var MikroOrmCoreModule_1;
|
||||
import { Configuration, EntityManager, MikroORM } from '@mikro-orm/core';
|
||||
import { Global, Inject, Module, RequestMethod, } from '@nestjs/common';
|
||||
// oxlint-disable-next-line consistent-type-imports
|
||||
import { ModuleRef } from '@nestjs/core';
|
||||
import { forRoutesPath } from './middleware.helper.js';
|
||||
import { CONTEXT_NAMES, getEntityManagerToken, getMikroORMToken, MIKRO_ORM_MODULE_OPTIONS, } from './mikro-orm.common.js';
|
||||
import { MikroOrmEntitiesStorage } from './mikro-orm.entities.storage.js';
|
||||
import { MikroOrmMiddleware } from './mikro-orm.middleware.js';
|
||||
import { createAsyncProviders, createEntityManagerProvider, createMikroOrmProvider } from './mikro-orm.providers.js';
|
||||
let MikroOrmCoreModule = MikroOrmCoreModule_1 = class MikroOrmCoreModule {
|
||||
options;
|
||||
moduleRef;
|
||||
constructor(options, moduleRef) {
|
||||
this.options = options;
|
||||
this.moduleRef = moduleRef;
|
||||
}
|
||||
static async forRoot(options) {
|
||||
const contextName = this.setContextName(options.contextName);
|
||||
const em = await this.createEntityManager(options);
|
||||
return this.buildDynamicModule(em, contextName, options, [
|
||||
{ provide: MIKRO_ORM_MODULE_OPTIONS, useValue: options },
|
||||
]);
|
||||
}
|
||||
static async forRootAsync(options) {
|
||||
const contextName = this.setContextName(options.contextName);
|
||||
const em = await this.createEntityManager(options);
|
||||
return this.buildDynamicModule(em, contextName, options, [...(options.providers || []), ...createAsyncProviders({ ...options, contextName: options.contextName })], options.imports || []);
|
||||
}
|
||||
static buildDynamicModule(em, contextName, options, baseProviders, imports = []) {
|
||||
if (em && !contextName) {
|
||||
return {
|
||||
module: MikroOrmCoreModule_1,
|
||||
imports,
|
||||
providers: [
|
||||
...baseProviders,
|
||||
createMikroOrmProvider(contextName),
|
||||
createMikroOrmProvider(contextName, em.getDriver().getORMClass()),
|
||||
createEntityManagerProvider(options.scope, EntityManager, undefined, options.forkOptions),
|
||||
createEntityManagerProvider(options.scope, em.constructor, undefined, options.forkOptions),
|
||||
],
|
||||
exports: [MikroORM, EntityManager, em.constructor, em.getDriver().getORMClass()],
|
||||
};
|
||||
}
|
||||
return {
|
||||
module: MikroOrmCoreModule_1,
|
||||
imports,
|
||||
providers: [
|
||||
...baseProviders,
|
||||
createMikroOrmProvider(contextName),
|
||||
...(em ? [createMikroOrmProvider(contextName, em.getDriver().getORMClass())] : []),
|
||||
createEntityManagerProvider(options.scope, EntityManager, contextName, options.forkOptions),
|
||||
...(em ? [createEntityManagerProvider(options.scope, em.constructor, contextName, options.forkOptions)] : []),
|
||||
],
|
||||
exports: [
|
||||
contextName ? getMikroORMToken(contextName) : MikroORM,
|
||||
contextName ? getEntityManagerToken(contextName) : EntityManager,
|
||||
...(em && !contextName ? [em.constructor, em.getDriver().getORMClass()] : []),
|
||||
],
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Tries to create the driver instance to use the actual entity manager implementation for DI symbol.
|
||||
* This helps with dependency resolution issues when importing the EM from driver package (e.g. `SqlEntityManager`).
|
||||
*/
|
||||
static async createEntityManager(options) {
|
||||
if (options.contextName) {
|
||||
return undefined;
|
||||
}
|
||||
try {
|
||||
let config;
|
||||
if (typeof options === 'object' && options && 'driver' in options && !('useFactory' in options)) {
|
||||
config = new Configuration(options, false);
|
||||
}
|
||||
// For async options with explicit driver hint, create a minimal config for EM type detection
|
||||
if (!config && 'driver' in options && options.driver) {
|
||||
config = new Configuration({ driver: options.driver }, false);
|
||||
}
|
||||
if (!config && 'useFactory' in options) {
|
||||
config = new Configuration(await options.useFactory(), false);
|
||||
}
|
||||
if (!config && options instanceof Configuration) {
|
||||
config = options;
|
||||
}
|
||||
return config?.getDriver().createEntityManager();
|
||||
}
|
||||
catch {
|
||||
if (options &&
|
||||
'useFactory' in options &&
|
||||
'inject' in options &&
|
||||
!options.driver &&
|
||||
options.inject.length > 0) {
|
||||
// oxlint-disable-next-line no-console
|
||||
console.warn('Support for driver specific imports in modules defined with `useFactory` and `inject` requires an explicit `driver` option. See https://github.com/mikro-orm/nestjs/pull/204');
|
||||
}
|
||||
}
|
||||
}
|
||||
async onApplicationShutdown() {
|
||||
const token = this.options.contextName ? getMikroORMToken(this.options.contextName) : MikroORM;
|
||||
const orm = this.moduleRef.get(token);
|
||||
if (orm) {
|
||||
await orm.close();
|
||||
MikroOrmEntitiesStorage.clearLater();
|
||||
}
|
||||
CONTEXT_NAMES.length = 0;
|
||||
}
|
||||
configure(consumer) {
|
||||
if (this.options.registerRequestContext === false) {
|
||||
return;
|
||||
}
|
||||
consumer
|
||||
.apply(MikroOrmMiddleware) // register request context automatically
|
||||
.forRoutes({ path: forRoutesPath(this.options, consumer), method: RequestMethod.ALL });
|
||||
}
|
||||
static setContextName(contextName) {
|
||||
if (!contextName) {
|
||||
return;
|
||||
}
|
||||
if (CONTEXT_NAMES.includes(contextName)) {
|
||||
throw new Error(`ContextName '${contextName}' already registered`);
|
||||
}
|
||||
CONTEXT_NAMES.push(contextName);
|
||||
return contextName;
|
||||
}
|
||||
};
|
||||
MikroOrmCoreModule = MikroOrmCoreModule_1 = __decorate([
|
||||
Global(),
|
||||
Module({}),
|
||||
__param(0, Inject(MIKRO_ORM_MODULE_OPTIONS)),
|
||||
__metadata("design:paramtypes", [Object, ModuleRef])
|
||||
], MikroOrmCoreModule);
|
||||
export { MikroOrmCoreModule };
|
||||
23
node_modules/@mikro-orm/nestjs/mikro-orm-middleware.module.d.ts
generated
vendored
Normal file
23
node_modules/@mikro-orm/nestjs/mikro-orm-middleware.module.d.ts
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
import { type MiddlewareConsumer, type NestModule } from '@nestjs/common';
|
||||
import type { MikroORM } from '@mikro-orm/core';
|
||||
import type { MikroOrmMiddlewareModuleOptions } from './typings.js';
|
||||
export declare class MikroOrmMiddlewareModule implements NestModule {
|
||||
private readonly options;
|
||||
constructor(options: MikroOrmMiddlewareModuleOptions);
|
||||
static forRoot(options?: MikroOrmMiddlewareModuleOptions): {
|
||||
module: typeof MikroOrmMiddlewareModule;
|
||||
providers: ({
|
||||
provide: symbol;
|
||||
useValue: MikroOrmMiddlewareModuleOptions;
|
||||
useFactory?: undefined;
|
||||
inject?: undefined;
|
||||
} | {
|
||||
provide: string;
|
||||
useFactory: (...args: MikroORM[]) => MikroORM<import("@mikro-orm/core").IDatabaseDriver<import("@mikro-orm/core").Connection>, import("@mikro-orm/core").EntityManager<import("@mikro-orm/core").IDatabaseDriver<import("@mikro-orm/core").Connection>>, (string | import("@mikro-orm/core").EntitySchema<any, never> | import("@mikro-orm/core").EntityClass<Partial<any>>)[]>[];
|
||||
inject: string[];
|
||||
useValue?: undefined;
|
||||
})[];
|
||||
exports: string[];
|
||||
};
|
||||
configure(consumer: MiddlewareConsumer): void;
|
||||
}
|
||||
50
node_modules/@mikro-orm/nestjs/mikro-orm-middleware.module.js
generated
vendored
Normal file
50
node_modules/@mikro-orm/nestjs/mikro-orm-middleware.module.js
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
var MikroOrmMiddlewareModule_1;
|
||||
import { Global, Inject, Module, RequestMethod } from '@nestjs/common';
|
||||
import { forRoutesPath } from './middleware.helper.js';
|
||||
import { CONTEXT_NAMES, getMikroORMToken, MIKRO_ORM_MODULE_OPTIONS } from './mikro-orm.common.js';
|
||||
import { MultipleMikroOrmMiddleware } from './multiple-mikro-orm.middleware.js';
|
||||
let MikroOrmMiddlewareModule = MikroOrmMiddlewareModule_1 = class MikroOrmMiddlewareModule {
|
||||
options;
|
||||
constructor(options) {
|
||||
this.options = options;
|
||||
}
|
||||
static forRoot(options) {
|
||||
const inject = CONTEXT_NAMES.map(name => getMikroORMToken(name));
|
||||
return {
|
||||
module: MikroOrmMiddlewareModule_1,
|
||||
providers: [
|
||||
{ provide: MIKRO_ORM_MODULE_OPTIONS, useValue: options || {} },
|
||||
{
|
||||
provide: 'MikroORMs',
|
||||
useFactory: (...args) => args,
|
||||
inject,
|
||||
},
|
||||
],
|
||||
exports: ['MikroORMs'],
|
||||
};
|
||||
}
|
||||
configure(consumer) {
|
||||
consumer
|
||||
.apply(MultipleMikroOrmMiddleware)
|
||||
.forRoutes({ path: forRoutesPath(this.options, consumer), method: RequestMethod.ALL });
|
||||
}
|
||||
};
|
||||
MikroOrmMiddlewareModule = MikroOrmMiddlewareModule_1 = __decorate([
|
||||
Global(),
|
||||
Module({}),
|
||||
__param(0, Inject(MIKRO_ORM_MODULE_OPTIONS)),
|
||||
__metadata("design:paramtypes", [Object])
|
||||
], MikroOrmMiddlewareModule);
|
||||
export { MikroOrmMiddlewareModule };
|
||||
52
node_modules/@mikro-orm/nestjs/mikro-orm.common.d.ts
generated
vendored
Normal file
52
node_modules/@mikro-orm/nestjs/mikro-orm.common.d.ts
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
import { Logger } from '@nestjs/common';
|
||||
import type { EntityName } from './typings.js';
|
||||
export declare const MIKRO_ORM_MODULE_OPTIONS: unique symbol;
|
||||
export declare const CONTEXT_NAMES: string[];
|
||||
export declare const logger: Logger;
|
||||
/**
|
||||
* Gets the injection token based on context name for the relevant MikroORM provider.
|
||||
* @param name The context name of the database connection.
|
||||
* @returns The MikroORM provider injection token for the supplied context name.
|
||||
*/
|
||||
export declare const getMikroORMToken: (name: string) => string;
|
||||
/**
|
||||
* Injects a MikroORM provider based on the supplied context name.
|
||||
*
|
||||
* @param name The context name of the database connection.
|
||||
* @returns A parameter decorator which will cause NestJS to inject the relevant MikroORM provider.
|
||||
*/
|
||||
export declare const InjectMikroORM: (name: string) => PropertyDecorator & ParameterDecorator;
|
||||
/**
|
||||
* Injects the MikroORMs provider.
|
||||
*
|
||||
* @returns A decorator which will cause NestJS to inject the MikroORMs provider.
|
||||
*/
|
||||
export declare const InjectMikroORMs: () => PropertyDecorator & ParameterDecorator;
|
||||
/**
|
||||
* Gets the injection token based on context name for the relevant EntityManager provider.
|
||||
* @param name The context name of the database connection.
|
||||
* @returns The EntityManager provider injection token for the supplied context name.
|
||||
*/
|
||||
export declare const getEntityManagerToken: (name: string) => string;
|
||||
/**
|
||||
* Injects an EntityManager provider based on the supplied context name.
|
||||
*
|
||||
* @param name The context name of the database connection.
|
||||
* @returns A parameter decorator which will cause NestJS to inject the relevant EntityManager provider.
|
||||
*/
|
||||
export declare const InjectEntityManager: (name: string) => PropertyDecorator & ParameterDecorator;
|
||||
/**
|
||||
* Gets the injection token based on class and optionally based on context name.
|
||||
* @param entity The class of the Entity to use for the injected repository provider.
|
||||
* @param name An optional context name - required for multiple database connections. See: [Multiple Database Connections](https://mikro-orm.io/docs/usage-with-nestjs#multiple-database-connections)
|
||||
* @returns The EntityRepository provider injection token based on the supplied entity and context name.
|
||||
*/
|
||||
export declare const getRepositoryToken: <T extends object>(entity: EntityName<T>, name?: string) => string;
|
||||
/**
|
||||
* Injects an EntityRepository provider.
|
||||
*
|
||||
* @param entity The class of the Entity to use for the injected repository provider.
|
||||
* @param name An optional context name - required for multiple database connections. See: [Multiple Database Connections](https://mikro-orm.io/docs/usage-with-nestjs#multiple-database-connections)
|
||||
* @returns A parameter decorator which will cause NestJS to inject the relevant EntityRepository provider.
|
||||
*/
|
||||
export declare const InjectRepository: <T extends object>(entity: EntityName<T>, name?: string) => PropertyDecorator & ParameterDecorator;
|
||||
55
node_modules/@mikro-orm/nestjs/mikro-orm.common.js
generated
vendored
Normal file
55
node_modules/@mikro-orm/nestjs/mikro-orm.common.js
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
import { MikroORM, Utils } from '@mikro-orm/core';
|
||||
import { Inject, Logger } from '@nestjs/common';
|
||||
export const MIKRO_ORM_MODULE_OPTIONS = Symbol('mikro-orm-module-options');
|
||||
export const CONTEXT_NAMES = [];
|
||||
export const logger = new Logger(MikroORM.name);
|
||||
/**
|
||||
* Gets the injection token based on context name for the relevant MikroORM provider.
|
||||
* @param name The context name of the database connection.
|
||||
* @returns The MikroORM provider injection token for the supplied context name.
|
||||
*/
|
||||
export const getMikroORMToken = (name) => `${name}_MikroORM`;
|
||||
/**
|
||||
* Injects a MikroORM provider based on the supplied context name.
|
||||
*
|
||||
* @param name The context name of the database connection.
|
||||
* @returns A parameter decorator which will cause NestJS to inject the relevant MikroORM provider.
|
||||
*/
|
||||
export const InjectMikroORM = (name) => Inject(getMikroORMToken(name));
|
||||
/**
|
||||
* Injects the MikroORMs provider.
|
||||
*
|
||||
* @returns A decorator which will cause NestJS to inject the MikroORMs provider.
|
||||
*/
|
||||
export const InjectMikroORMs = () => Inject('MikroORMs');
|
||||
/**
|
||||
* Gets the injection token based on context name for the relevant EntityManager provider.
|
||||
* @param name The context name of the database connection.
|
||||
* @returns The EntityManager provider injection token for the supplied context name.
|
||||
*/
|
||||
export const getEntityManagerToken = (name) => `${name}_EntityManager`;
|
||||
/**
|
||||
* Injects an EntityManager provider based on the supplied context name.
|
||||
*
|
||||
* @param name The context name of the database connection.
|
||||
* @returns A parameter decorator which will cause NestJS to inject the relevant EntityManager provider.
|
||||
*/
|
||||
export const InjectEntityManager = (name) => Inject(getEntityManagerToken(name));
|
||||
/**
|
||||
* Gets the injection token based on class and optionally based on context name.
|
||||
* @param entity The class of the Entity to use for the injected repository provider.
|
||||
* @param name An optional context name - required for multiple database connections. See: [Multiple Database Connections](https://mikro-orm.io/docs/usage-with-nestjs#multiple-database-connections)
|
||||
* @returns The EntityRepository provider injection token based on the supplied entity and context name.
|
||||
*/
|
||||
export const getRepositoryToken = (entity, name) => {
|
||||
const suffix = name ? `_${name}` : '';
|
||||
return `${Utils.className(entity)}Repository${suffix}`;
|
||||
};
|
||||
/**
|
||||
* Injects an EntityRepository provider.
|
||||
*
|
||||
* @param entity The class of the Entity to use for the injected repository provider.
|
||||
* @param name An optional context name - required for multiple database connections. See: [Multiple Database Connections](https://mikro-orm.io/docs/usage-with-nestjs#multiple-database-connections)
|
||||
* @returns A parameter decorator which will cause NestJS to inject the relevant EntityRepository provider.
|
||||
*/
|
||||
export const InjectRepository = (entity, name) => Inject(getRepositoryToken(entity, name));
|
||||
15
node_modules/@mikro-orm/nestjs/mikro-orm.entities.storage.d.ts
generated
vendored
Normal file
15
node_modules/@mikro-orm/nestjs/mikro-orm.entities.storage.d.ts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import type { AnyEntity } from '@mikro-orm/core';
|
||||
import type { EntityName } from './typings.js';
|
||||
export declare class MikroOrmEntitiesStorage {
|
||||
private static readonly storage;
|
||||
private static shouldClear;
|
||||
static addEntity(entity: EntityName<AnyEntity>, contextName?: string): void;
|
||||
static getEntities(contextName?: string): never[] | SetIterator<EntityName<Partial<any>>>;
|
||||
static clear(contextName?: string): void;
|
||||
/**
|
||||
* When the `addEntity` is called next, the storage will be cleared automatically before it.
|
||||
* We want to keep the cache, as it's populated on require time, but sometimes (tests) the contexts could be cleared.
|
||||
* This resolves both cases by deferring the `clear` call to the first `addEntity` call.
|
||||
*/
|
||||
static clearLater(): void;
|
||||
}
|
||||
30
node_modules/@mikro-orm/nestjs/mikro-orm.entities.storage.js
generated
vendored
Normal file
30
node_modules/@mikro-orm/nestjs/mikro-orm.entities.storage.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
export class MikroOrmEntitiesStorage {
|
||||
static storage = new Map();
|
||||
static shouldClear = false;
|
||||
static addEntity(entity, contextName = 'default') {
|
||||
if (this.shouldClear) {
|
||||
this.clear(contextName);
|
||||
this.shouldClear = false;
|
||||
}
|
||||
let set = this.storage.get(contextName);
|
||||
if (!set) {
|
||||
set = new Set();
|
||||
this.storage.set(contextName, set);
|
||||
}
|
||||
set.add(entity);
|
||||
}
|
||||
static getEntities(contextName = 'default') {
|
||||
return this.storage.get(contextName)?.values() || [];
|
||||
}
|
||||
static clear(contextName = 'default') {
|
||||
this.storage.get(contextName)?.clear();
|
||||
}
|
||||
/**
|
||||
* When the `addEntity` is called next, the storage will be cleared automatically before it.
|
||||
* We want to keep the cache, as it's populated on require time, but sometimes (tests) the contexts could be cleared.
|
||||
* This resolves both cases by deferring the `clear` call to the first `addEntity` call.
|
||||
*/
|
||||
static clearLater() {
|
||||
this.shouldClear = true;
|
||||
}
|
||||
}
|
||||
7
node_modules/@mikro-orm/nestjs/mikro-orm.middleware.d.ts
generated
vendored
Normal file
7
node_modules/@mikro-orm/nestjs/mikro-orm.middleware.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import { MikroORM } from '@mikro-orm/core';
|
||||
import { type NestMiddleware } from '@nestjs/common';
|
||||
export declare class MikroOrmMiddleware implements NestMiddleware {
|
||||
private readonly orm;
|
||||
constructor(orm: MikroORM);
|
||||
use(req: unknown, res: unknown, next: (...args: any[]) => void): void;
|
||||
}
|
||||
26
node_modules/@mikro-orm/nestjs/mikro-orm.middleware.js
generated
vendored
Normal file
26
node_modules/@mikro-orm/nestjs/mikro-orm.middleware.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
// oxlint-disable-next-line consistent-type-imports
|
||||
import { MikroORM, RequestContext } from '@mikro-orm/core';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
let MikroOrmMiddleware = class MikroOrmMiddleware {
|
||||
orm;
|
||||
constructor(orm) {
|
||||
this.orm = orm;
|
||||
}
|
||||
use(req, res, next) {
|
||||
RequestContext.create(this.orm.em, next);
|
||||
}
|
||||
};
|
||||
MikroOrmMiddleware = __decorate([
|
||||
Injectable(),
|
||||
__metadata("design:paramtypes", [MikroORM])
|
||||
], MikroOrmMiddleware);
|
||||
export { MikroOrmMiddleware };
|
||||
16
node_modules/@mikro-orm/nestjs/mikro-orm.module.d.ts
generated
vendored
Normal file
16
node_modules/@mikro-orm/nestjs/mikro-orm.module.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import { type AnyEntity } from '@mikro-orm/core';
|
||||
import { type DynamicModule } from '@nestjs/common';
|
||||
import type { EntityName, MikroOrmModuleAsyncOptions, MikroOrmModuleFeatureOptions, MikroOrmModuleSyncOptions, MikroOrmMiddlewareModuleOptions, MaybePromise } from './typings.js';
|
||||
export declare class MikroOrmModule {
|
||||
/**
|
||||
* Clears the entity storage. This is useful for testing purposes, when you want to isolate the tests.
|
||||
* Keep in mind that this should be called when using a test runner that keeps the context alive between tests (like Vitest with threads disabled).
|
||||
*/
|
||||
static clearStorage(contextName?: string): void;
|
||||
static forRoot(options: MikroOrmModuleSyncOptions): MaybePromise<DynamicModule>;
|
||||
static forRoot(options: MikroOrmModuleSyncOptions[]): MaybePromise<DynamicModule>[];
|
||||
static forRootAsync(options: MikroOrmModuleAsyncOptions): MaybePromise<DynamicModule>;
|
||||
static forRootAsync(options: MikroOrmModuleAsyncOptions[]): MaybePromise<DynamicModule>[];
|
||||
static forFeature(options: EntityName<AnyEntity>[] | MikroOrmModuleFeatureOptions, contextName?: string): DynamicModule;
|
||||
static forMiddleware(options?: MikroOrmMiddlewareModuleOptions): DynamicModule;
|
||||
}
|
||||
55
node_modules/@mikro-orm/nestjs/mikro-orm.module.js
generated
vendored
Normal file
55
node_modules/@mikro-orm/nestjs/mikro-orm.module.js
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var MikroOrmModule_1;
|
||||
import { Module } from '@nestjs/common';
|
||||
import { MikroOrmCoreModule } from './mikro-orm-core.module.js';
|
||||
import { MikroOrmMiddlewareModule } from './mikro-orm-middleware.module.js';
|
||||
import { MikroOrmEntitiesStorage } from './mikro-orm.entities.storage.js';
|
||||
import { createMikroOrmRepositoryProviders } from './mikro-orm.providers.js';
|
||||
let MikroOrmModule = MikroOrmModule_1 = class MikroOrmModule {
|
||||
/**
|
||||
* Clears the entity storage. This is useful for testing purposes, when you want to isolate the tests.
|
||||
* Keep in mind that this should be called when using a test runner that keeps the context alive between tests (like Vitest with threads disabled).
|
||||
*/
|
||||
static clearStorage(contextName) {
|
||||
MikroOrmEntitiesStorage.clear(contextName);
|
||||
}
|
||||
static forRoot(options) {
|
||||
if (Array.isArray(options)) {
|
||||
return options.map(o => MikroOrmCoreModule.forRoot(o));
|
||||
}
|
||||
return MikroOrmCoreModule.forRoot(options);
|
||||
}
|
||||
static forRootAsync(options) {
|
||||
if (Array.isArray(options)) {
|
||||
return options.map(o => MikroOrmCoreModule.forRootAsync(o));
|
||||
}
|
||||
return MikroOrmCoreModule.forRootAsync(options);
|
||||
}
|
||||
static forFeature(options, contextName) {
|
||||
const entities = Array.isArray(options) ? options : options.entities || [];
|
||||
const name = Array.isArray(options) || contextName ? contextName : options.contextName;
|
||||
const providers = createMikroOrmRepositoryProviders(entities, name);
|
||||
for (const e of entities) {
|
||||
if (typeof e !== 'string') {
|
||||
MikroOrmEntitiesStorage.addEntity(e, name);
|
||||
}
|
||||
}
|
||||
return {
|
||||
module: MikroOrmModule_1,
|
||||
providers: [...providers],
|
||||
exports: [...providers],
|
||||
};
|
||||
}
|
||||
static forMiddleware(options) {
|
||||
return MikroOrmMiddlewareModule.forRoot(options);
|
||||
}
|
||||
};
|
||||
MikroOrmModule = MikroOrmModule_1 = __decorate([
|
||||
Module({})
|
||||
], MikroOrmModule);
|
||||
export { MikroOrmModule };
|
||||
8
node_modules/@mikro-orm/nestjs/mikro-orm.providers.d.ts
generated
vendored
Normal file
8
node_modules/@mikro-orm/nestjs/mikro-orm.providers.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { EntityManager, type AnyEntity, type ForkOptions } from '@mikro-orm/core';
|
||||
import { Scope, type Provider, type Type } from '@nestjs/common';
|
||||
import type { EntityName, MikroOrmModuleAsyncOptions } from './typings.js';
|
||||
export declare function createMikroOrmProvider(contextName?: string, type?: Type): Provider;
|
||||
export declare function createEntityManagerProvider(scope?: Scope, entityManager?: Type, contextName?: string, forkOptions?: ForkOptions): Provider<EntityManager>;
|
||||
export declare function createMikroOrmAsyncOptionsProvider(options: MikroOrmModuleAsyncOptions): Provider;
|
||||
export declare function createAsyncProviders(options: MikroOrmModuleAsyncOptions): Provider[];
|
||||
export declare function createMikroOrmRepositoryProviders(entities: EntityName<AnyEntity>[], contextName?: string): Provider[];
|
||||
102
node_modules/@mikro-orm/nestjs/mikro-orm.providers.js
generated
vendored
Normal file
102
node_modules/@mikro-orm/nestjs/mikro-orm.providers.js
generated
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
import { EntityManager, EntitySchema, MetadataStorage, MikroORM } from '@mikro-orm/core';
|
||||
import { Scope } from '@nestjs/common';
|
||||
import { MIKRO_ORM_MODULE_OPTIONS, getEntityManagerToken, getMikroORMToken, getRepositoryToken, logger, } from './mikro-orm.common.js';
|
||||
import { MikroOrmEntitiesStorage } from './mikro-orm.entities.storage.js';
|
||||
export function createMikroOrmProvider(contextName, type = MikroORM) {
|
||||
if (!contextName && type !== MikroORM) {
|
||||
return {
|
||||
provide: type,
|
||||
useFactory: orm => orm, // just a simple alias
|
||||
inject: [MikroORM], // depend on the ORM from core package
|
||||
};
|
||||
}
|
||||
return {
|
||||
provide: contextName ? getMikroORMToken(contextName) : type,
|
||||
useFactory: async (options) => {
|
||||
options = { logger: logger.log.bind(logger), ...options };
|
||||
if (options.autoLoadEntities) {
|
||||
options.entities = [
|
||||
...(options.entities || []),
|
||||
...MikroOrmEntitiesStorage.getEntities(contextName),
|
||||
];
|
||||
options.entitiesTs = [
|
||||
...(options.entitiesTs || []),
|
||||
...MikroOrmEntitiesStorage.getEntities(contextName),
|
||||
];
|
||||
delete options.autoLoadEntities;
|
||||
}
|
||||
return MikroORM.init(options);
|
||||
},
|
||||
inject: [MIKRO_ORM_MODULE_OPTIONS],
|
||||
};
|
||||
}
|
||||
export function createEntityManagerProvider(scope = Scope.DEFAULT, entityManager = EntityManager, contextName, forkOptions) {
|
||||
if (!contextName && entityManager !== EntityManager) {
|
||||
return {
|
||||
provide: entityManager,
|
||||
scope,
|
||||
useFactory: (em) => em, // just a simple alias, unlike `useExisting` from nest, this works with request scopes too
|
||||
inject: [EntityManager], // depend on the EM from core package
|
||||
};
|
||||
}
|
||||
return {
|
||||
provide: contextName ? getEntityManagerToken(contextName) : entityManager,
|
||||
scope,
|
||||
useFactory: (orm) => (scope === Scope.DEFAULT ? orm.em : orm.em.fork({ useContext: true, ...forkOptions })),
|
||||
inject: [contextName ? getMikroORMToken(contextName) : MikroORM],
|
||||
};
|
||||
}
|
||||
export function createMikroOrmAsyncOptionsProvider(options) {
|
||||
if (options.useFactory) {
|
||||
return {
|
||||
provide: MIKRO_ORM_MODULE_OPTIONS,
|
||||
useFactory: async (...args) => {
|
||||
const factoryOptions = await options.useFactory(...args);
|
||||
return options.contextName ? { contextName: options.contextName, ...factoryOptions } : factoryOptions;
|
||||
},
|
||||
inject: options.inject || [],
|
||||
};
|
||||
}
|
||||
const inject = [];
|
||||
if (options.useClass || options.useExisting) {
|
||||
inject.push(options.useClass ?? options.useExisting);
|
||||
}
|
||||
return {
|
||||
provide: MIKRO_ORM_MODULE_OPTIONS,
|
||||
useFactory: async (optionsFactory) => await optionsFactory.createMikroOrmOptions(options.contextName),
|
||||
inject,
|
||||
};
|
||||
}
|
||||
export function createAsyncProviders(options) {
|
||||
if (options.useExisting || options.useFactory) {
|
||||
return [createMikroOrmAsyncOptionsProvider(options)];
|
||||
}
|
||||
if (options.useClass) {
|
||||
return [createMikroOrmAsyncOptionsProvider(options), { provide: options.useClass, useClass: options.useClass }];
|
||||
}
|
||||
throw new Error('Invalid MikroORM async options: one of `useClass`, `useExisting` or `useFactory` should be defined.');
|
||||
}
|
||||
export function createMikroOrmRepositoryProviders(entities, contextName) {
|
||||
const metadata = Object.values(MetadataStorage.getMetadata());
|
||||
const providers = [];
|
||||
const inject = contextName ? getEntityManagerToken(contextName) : EntityManager;
|
||||
(entities || []).forEach(entity => {
|
||||
const meta = entity instanceof EntitySchema
|
||||
? entity.meta
|
||||
: (typeof entity === 'function' ? EntitySchema.REGISTRY.get(entity)?.meta : undefined) ?? metadata.find(meta => meta.class === entity);
|
||||
const repository = meta?.repository;
|
||||
if (repository) {
|
||||
providers.push({
|
||||
provide: repository(),
|
||||
useFactory: em => em.getRepository(entity),
|
||||
inject: [inject],
|
||||
});
|
||||
}
|
||||
providers.push({
|
||||
provide: getRepositoryToken(entity, contextName),
|
||||
useFactory: em => em.getRepository(entity),
|
||||
inject: [inject],
|
||||
});
|
||||
});
|
||||
return providers;
|
||||
}
|
||||
7
node_modules/@mikro-orm/nestjs/multiple-mikro-orm.middleware.d.ts
generated
vendored
Normal file
7
node_modules/@mikro-orm/nestjs/multiple-mikro-orm.middleware.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import { type MikroORM } from '@mikro-orm/core';
|
||||
import { type NestMiddleware } from '@nestjs/common';
|
||||
export declare class MultipleMikroOrmMiddleware implements NestMiddleware {
|
||||
private readonly orm;
|
||||
constructor(orm: MikroORM[]);
|
||||
use(req: unknown, res: unknown, next: (...args: any[]) => void): void;
|
||||
}
|
||||
30
node_modules/@mikro-orm/nestjs/multiple-mikro-orm.middleware.js
generated
vendored
Normal file
30
node_modules/@mikro-orm/nestjs/multiple-mikro-orm.middleware.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
import { RequestContext } from '@mikro-orm/core';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectMikroORMs } from './mikro-orm.common.js';
|
||||
let MultipleMikroOrmMiddleware = class MultipleMikroOrmMiddleware {
|
||||
orm;
|
||||
constructor(orm) {
|
||||
this.orm = orm;
|
||||
}
|
||||
use(req, res, next) {
|
||||
RequestContext.create(this.orm.map(orm => orm.em), next);
|
||||
}
|
||||
};
|
||||
MultipleMikroOrmMiddleware = __decorate([
|
||||
Injectable(),
|
||||
__param(0, InjectMikroORMs()),
|
||||
__metadata("design:paramtypes", [Array])
|
||||
], MultipleMikroOrmMiddleware);
|
||||
export { MultipleMikroOrmMiddleware };
|
||||
117
node_modules/@mikro-orm/nestjs/package.json
generated
vendored
Normal file
117
node_modules/@mikro-orm/nestjs/package.json
generated
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
{
|
||||
"name": "@mikro-orm/nestjs",
|
||||
"version": "7.0.1",
|
||||
"description": "NestJS module for MikroORM",
|
||||
"keywords": [
|
||||
"data-mapper",
|
||||
"ddd",
|
||||
"entity",
|
||||
"identity-map",
|
||||
"mikro-orm",
|
||||
"mongo",
|
||||
"mongodb",
|
||||
"mysql",
|
||||
"nestjs",
|
||||
"orm",
|
||||
"postgresql",
|
||||
"sqlite",
|
||||
"unit-of-work"
|
||||
],
|
||||
"homepage": "https://github.com/mikro-orm/nestjs#readme",
|
||||
"bugs": "https://github.com/mikro-orm/nestjs/issues",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/mikro-orm/nestjs"
|
||||
},
|
||||
"author": {
|
||||
"name": "Martin Adamek",
|
||||
"email": "banan23@gmail.com"
|
||||
},
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": "./index.js",
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "yarn clean && yarn compile && yarn copy",
|
||||
"clean": "rimraf ./dist",
|
||||
"compile": "tsc -p tsconfig.build.json",
|
||||
"copy": "node ./scripts/copy.mjs",
|
||||
"test": "vitest run",
|
||||
"tsc-check-tests": "tsc --noEmit --project tests/tsconfig.json",
|
||||
"format": "oxfmt --write .",
|
||||
"lint": "oxlint --type-aware",
|
||||
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 1",
|
||||
"coverage": "yarn test --coverage"
|
||||
},
|
||||
"commitlint": {
|
||||
"extends": [
|
||||
"@commitlint/config-conventional"
|
||||
]
|
||||
},
|
||||
"lint-staged": {
|
||||
"*": "oxfmt --no-error-on-unmatched-pattern"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@mikro-orm/core": "^7.0.0-dev.109",
|
||||
"@mikro-orm/decorators": "^7.0.0-dev.109",
|
||||
"@mikro-orm/sqlite": "^7.0.0-dev.109",
|
||||
"@nestjs/common": "^11.1.9",
|
||||
"@nestjs/core": "^11.1.9",
|
||||
"@nestjs/platform-express": "^11.1.9",
|
||||
"@nestjs/testing": "^11.1.9",
|
||||
"@swc/core": "^1.15.5",
|
||||
"@types/node": "^25.0.1",
|
||||
"@types/supertest": "^7.0.0",
|
||||
"@vitest/coverage-v8": "^4.0.16",
|
||||
"conventional-changelog": "^7.1.1",
|
||||
"conventional-changelog-cli": "^5.0.0",
|
||||
"oxfmt": "^0.38.0",
|
||||
"oxlint": "^1.33.0",
|
||||
"oxlint-tsgolint": "^0.16.0",
|
||||
"reflect-metadata": "^0.2.2",
|
||||
"rimraf": "^6.1.2",
|
||||
"rxjs": "^7.8.2",
|
||||
"supertest": "^7.1.4",
|
||||
"typescript": "5.9.3",
|
||||
"unplugin-swc": "^1.5.9",
|
||||
"vitest": "^4.0.16"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@mikro-orm/core": "^7.0.0 || ^7.0.0-dev.0",
|
||||
"@nestjs/common": "^11.0.5",
|
||||
"@nestjs/core": "^11.0.5",
|
||||
"reflect-metadata": "^0.1.0 || ^0.2.0"
|
||||
},
|
||||
"packageManager": "yarn@4.12.0",
|
||||
"engines": {
|
||||
"node": ">= 22.17.0"
|
||||
},
|
||||
"readme": "./README.md",
|
||||
"renovate": {
|
||||
"extends": [
|
||||
"config:base",
|
||||
":preserveSemverRanges",
|
||||
":semanticCommitTypeAll(chore)"
|
||||
],
|
||||
"semanticCommits": "enabled",
|
||||
"separateMajorMinor": false,
|
||||
"dependencyDashboard": false,
|
||||
"packageRules": [
|
||||
{
|
||||
"matchUpdateTypes": [
|
||||
"patch",
|
||||
"minor"
|
||||
],
|
||||
"groupName": "patch/minor dependencies",
|
||||
"groupSlug": "all-non-major",
|
||||
"automerge": true,
|
||||
"automergeType": "branch"
|
||||
}
|
||||
],
|
||||
"schedule": [
|
||||
"every weekday"
|
||||
]
|
||||
}
|
||||
}
|
||||
82
node_modules/@mikro-orm/nestjs/typings.d.ts
generated
vendored
Normal file
82
node_modules/@mikro-orm/nestjs/typings.d.ts
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
import type { AnyEntity, Constructor, EntityName as CoreEntityName, EntitySchema, ForkOptions, IDatabaseDriver, Options } from '@mikro-orm/core';
|
||||
import type { MiddlewareConsumer, ModuleMetadata, Scope, Type } from '@nestjs/common';
|
||||
import type { AbstractHttpAdapter } from '@nestjs/core';
|
||||
export type MaybePromise<T> = T | Promise<T>;
|
||||
export interface NestMiddlewareConsumer extends MiddlewareConsumer {
|
||||
httpAdapter: AbstractHttpAdapter;
|
||||
}
|
||||
type MikroOrmNestScopeOptions = {
|
||||
/**
|
||||
* The NestJS provider scope to use for the EntityManager (and any subsequent downstream records).
|
||||
*
|
||||
* This scope will also impact the scope of Entity Repositories as they depend on the EntityManager.
|
||||
*
|
||||
* @see [NestJS Scope Hierarchy](https://docs.nestjs.com/fundamentals/injection-scopes#scope-hierarchy)
|
||||
*/
|
||||
scope?: Scope;
|
||||
/**
|
||||
* An optional configuration object to use when forking the Event Manager if it is configured with a scope other than Scope.DEFAULT
|
||||
*
|
||||
* This configuration option has no effect when the scope is set to Scope.DEFAULT.
|
||||
*
|
||||
* https://mikro-orm.io/api/core/interface/ForkOptions
|
||||
*/
|
||||
forkOptions?: ForkOptions;
|
||||
};
|
||||
export type MikroOrmMiddlewareModuleOptions = {
|
||||
/**
|
||||
* Routes to apply the middleware.
|
||||
*
|
||||
* For Fastify, the middleware applies to all routes using `(.*)`.
|
||||
*
|
||||
* For all other frameworks including Express, the middleware applies to all routes using `*`.
|
||||
*/
|
||||
forRoutesPath?: string;
|
||||
};
|
||||
export type MikroOrmModuleOptions<D extends IDatabaseDriver = IDatabaseDriver> = {
|
||||
registerRequestContext?: boolean;
|
||||
/**
|
||||
* Specifies whether or not to automatically load the entities based on MikroOrmModule.forFeature invocations.
|
||||
*
|
||||
* @see [MikroOrm - NestJS - Load Entities Automatically](https://mikro-orm.io/docs/usage-with-nestjs#load-entities-automatically)
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
autoLoadEntities?: boolean;
|
||||
} & Partial<Options<D>> & MikroOrmMiddlewareModuleOptions;
|
||||
export interface MikroOrmModuleFeatureOptions {
|
||||
/**
|
||||
* The entities to provide an EntityRepository for.
|
||||
*
|
||||
* @see [MikroOrm - NestJS - Repositories](https://mikro-orm.io/docs/usage-with-nestjs#repositories)
|
||||
*/
|
||||
entities?: EntityName<AnyEntity>[];
|
||||
/**
|
||||
* The context (database connection) to use for the entity repository.
|
||||
*
|
||||
* @see [MikroOrm - NestJS - Multiple Database Connections](https://mikro-orm.io/docs/usage-with-nestjs#multiple-database-connections)
|
||||
*/
|
||||
contextName?: string;
|
||||
}
|
||||
export interface MikroOrmOptionsFactory<D extends IDatabaseDriver = IDatabaseDriver> {
|
||||
createMikroOrmOptions(contextName?: string): Promise<MikroOrmModuleOptions<D>> | MikroOrmModuleOptions<D>;
|
||||
}
|
||||
export interface MikroOrmModuleSyncOptions extends MikroOrmModuleOptions, MikroOrmNestScopeOptions {
|
||||
}
|
||||
export interface MikroOrmModuleAsyncOptions<D extends IDatabaseDriver = IDatabaseDriver> extends Pick<ModuleMetadata, 'imports' | 'providers'>, MikroOrmNestScopeOptions {
|
||||
/**
|
||||
* The context name (database connection) to specify for this instance.
|
||||
*
|
||||
* When injecting repositories or entity manager instances, this context name will need to be specified where there are multiple datbaase connections.
|
||||
*
|
||||
* @see [MikroOrm - NestJS - Multiple Database Connections](https://mikro-orm.io/docs/usage-with-nestjs#multiple-database-connections)
|
||||
*/
|
||||
contextName?: string;
|
||||
useExisting?: Type<MikroOrmOptionsFactory<D>>;
|
||||
useClass?: Type<MikroOrmOptionsFactory<D>>;
|
||||
useFactory?: (...args: any[]) => Promise<Omit<MikroOrmModuleOptions<D>, 'contextName'>> | Omit<MikroOrmModuleOptions<D>, 'contextName'>;
|
||||
driver?: Constructor<D>;
|
||||
inject?: any[];
|
||||
}
|
||||
export declare type EntityName<T extends AnyEntity<T>> = CoreEntityName<T> | EntitySchema;
|
||||
export {};
|
||||
1
node_modules/@mikro-orm/nestjs/typings.js
generated
vendored
Normal file
1
node_modules/@mikro-orm/nestjs/typings.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
Reference in New Issue
Block a user