@automapper-add-on/mikro-premap
v1.0.2
Published
Mikro preMap for @automapper
Downloads
63
Maintainers
Readme
MikroORM's preMap for @automapper.
Install
npm install --save @automapper-add-on/mikro-premap
# or
yarn add @automapper-add-on/mikro-premap
# or
pnpm add @automapper-add-on/mikro-premap
Usage
import { MikroORM } from '@mikro-orm/core';
import { classes } from '@automapper/classes';
import { AutomapperModule } from '@automapper/nestjs';
import { mikro } from '@automapper-add-on/mikro-premap';
import { MikroOrmMiddleware, MikroOrmModule } from '@mikro-orm/nestjs';
import {
Module,
type NestModule,
type OnModuleInit,
type MiddlewareConsumer,
} from '@nestjs/common';
@Module({
imports: [
MikroOrmModule.forRoot(),
AutomapperModule.forRoot([
{
name: 'default',
strategyInitializer: mikro(),
},
{
name: 'classes',
strategyInitializer: classes(),
},
]),
],
})
export class AppModule implements NestModule, OnModuleInit {
constructor(private readonly orm: MikroORM) {}
async onModuleInit(): Promise<void> {
await this.orm.getMigrator().up();
}
configure(consumer: MiddlewareConsumer): void {
consumer.apply(MikroOrmMiddleware).forRoutes('*');
}
}