All Projects → nestjsx → Automapper

nestjsx / Automapper

Licence: mit
An Object-Object AutoMapper module for NestJS.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Automapper

Clinicmanagement
Clinic management project using Asp.net mvc5
Stars: ✭ 74 (-32.73%)
Mutual labels:  automapper
Autocopy
A automatic object-object copyer
Stars: ✭ 89 (-19.09%)
Mutual labels:  automapper
Nestjs Multer Extended
💪 Extended MulterModule for NestJS with flexible S3 upload and helpful features
Stars: ✭ 99 (-10%)
Mutual labels:  nestjs
Nestjs Cqrs Starter
NestJS CQRS Microservices Starter Project
Stars: ✭ 80 (-27.27%)
Mutual labels:  nestjs
Aspnetcore Ddd
Full ASP.NET Core 3.1 LTS application with DDD, CQRS and Event Sourcing
Stars: ✭ 88 (-20%)
Mutual labels:  automapper
Aspnetcore Realworld Example App
ASP.NET Core backend implementation for RealWorld
Stars: ✭ 1,315 (+1095.45%)
Mutual labels:  automapper
Nestjs Components
A list of useful components for NestJS applications
Stars: ✭ 72 (-34.55%)
Mutual labels:  nestjs
Nestjs Realworld Example App
Exemplary real world backend API built with NestJS + TypeORM / Prisma
Stars: ✭ 1,838 (+1570.91%)
Mutual labels:  nestjs
Vscode Nestjs Snippets
💥 Vscode NestJS Code Snippets
Stars: ✭ 88 (-20%)
Mutual labels:  nestjs
Nestjs Dataloader
Dataloader plugin for NestJS
Stars: ✭ 97 (-11.82%)
Mutual labels:  nestjs
Nestjs Sentry
Provides an injectable sentry.io client to provide enterprise logging nestjs modules
Stars: ✭ 80 (-27.27%)
Mutual labels:  nestjs
Sequelize
Sequelize module for Nest framework (node.js) 🍈
Stars: ✭ 88 (-20%)
Mutual labels:  nestjs
Nestjs Rate Limiter
Highly configurable rate limiter library built for NestJS
Stars: ✭ 93 (-15.45%)
Mutual labels:  nestjs
Nestjs Roles
Type safe roles guard and decorator made easy
Stars: ✭ 78 (-29.09%)
Mutual labels:  nestjs
Blog
Repository with all my blog projects
Stars: ✭ 101 (-8.18%)
Mutual labels:  nestjs
Drivine
Best and fastest graph database client (Neo4j & AgensGraph) for Node.js & TypeScript.
Stars: ✭ 74 (-32.73%)
Mutual labels:  nestjs
Abraham
小程序垃圾分类
Stars: ✭ 90 (-18.18%)
Mutual labels:  nestjs
Nest
A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications on top of TypeScript & JavaScript (ES6, ES7, ES8) 🚀
Stars: ✭ 42,981 (+38973.64%)
Mutual labels:  nestjs
Ng Nest
NG-NEST 是一个开源的 Web 应用程序框架,基于 Angular 和 Nest ,主要用于研发企业级中后台产品
Stars: ✭ 106 (-3.64%)
Mutual labels:  nestjs
Newschool Backend
Plataforma de ensino para pessoas carentes
Stars: ✭ 98 (-10.91%)
Mutual labels:  nestjs

travis npm downloads bundlephobia license coveralls Greenkeeper

NestJSX Automapper

A wrapper around @nartc/automapper to be used with NestJS as a Module.

Announcement

@nartc/automapper (which is what this wrapper wraps around) has been broken up into a monorepo and released as under the scope @automapper/*. With that change, NestJS wrapper is also under that same scope as @automapper/nestjs. Please take a look at the documentations for Migration Guide.

Migrations

Migrate to v3

forRoot() method will be deprecated soon (still available in v3). Please use withMapper() instead.

Documentations

This module is a wrapper around @nartc/automapper so all usage documentations should be referenced at the link below.

Github Pages https://automapper.netlify.com/ Github Repo https://github.com/nartc/mapper

Features

  • [x] Mapping between two classes
  • [x] Mapping for nested classes
  • [x] Array/List Mapping
  • [x] Flattening
  • [x] Basic ReverseMap
  • [x] Value Converters
  • [x] Value Resolvers
  • [x] Async
  • [x] Before/After Callback
  • [x] Naming Conventions (PascalCase and camelCase)

Contributions are appreciated.

Setup

npm i -s nestjsx-automapper

Installing nestjsx-automapper will also install @nartc/automapper.

Note 1: Please make sure that you've read @nartc/automapper documentations to familiarize yourself with AutoMapper's terminology and how to setup your Profile and such.

Setup

  1. Import AutomapperModule in AppModule and call .withMapper() method
@Module({
  imports: [AutomapperModule.withMapper()],
})
export class AppModule {}

AutomapperModule.withMapper() has the following overloads:

static withMapper(name?: string, options?: AutoMapperGlobalSettings);
static withMapper(options?: AutoMapperGlobalSettings);
  • name: Name of the AutoMapper instance being created with withMapper(). Default to "default"
  • options: Check AutoMapperGlobalSettings for more information
  1. nestjsx-automapper exposes a @Profile() decorator to decorate your Profile classes.
@Profile()
class UserProfile extends ProfileBase {}

@Profile() takes in an optional name argument. This is the name if the AutoMapper instance you use to create the instance with withMapper(). Default to "default"

Usually, NestJS will have many Feature Modules for each of the Domain Models. Hence, a Profile should stay in close to where the feature module is. If you want to separate Profile out to a separate file, then you need to make sure that file gets executed by importing it somewhere (again, the module is a good place).

  1. Inject the AutoMapper instance in your Injectable
@Injectable()
export class UserService {
  constructor(@InjectMapper() private readonly mapper: AutoMapper) {}
}

@InjectMapper() takes in an optional name argument which will tell the decorator which AutoMapper instance to inject. Default to "default"

InjectMapper is imported from nestjsx-automapper. AutoMapper is imported from @nartc/automapper

  1. Use AutoMapper on your models
// ...
const result = await newUser.save();
return this.mapper.map(result.toJSON(), UserVm, User);
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].