{"id":13598617,"url":"https://github.com/nestjsx/automapper","last_synced_at":"2025-04-10T09:31:40.561Z","repository":{"id":55207032,"uuid":"219324014","full_name":"nestjsx/automapper","owner":"nestjsx","description":"An Object-Object AutoMapper module for NestJS.","archived":true,"fork":false,"pushed_at":"2021-01-07T02:52:00.000Z","size":1415,"stargazers_count":122,"open_issues_count":11,"forks_count":7,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-29T22:37:19.381Z","etag":null,"topics":["automapper","nestjs","typescript"],"latest_commit_sha":null,"homepage":"https://nestjsx.github.io/automapper/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nestjsx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["nartc"]}},"created_at":"2019-11-03T15:42:28.000Z","updated_at":"2024-09-21T20:28:42.000Z","dependencies_parsed_at":"2022-08-14T16:10:32.197Z","dependency_job_id":null,"html_url":"https://github.com/nestjsx/automapper","commit_stats":null,"previous_names":[],"tags_count":73,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nestjsx%2Fautomapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nestjsx%2Fautomapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nestjsx%2Fautomapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nestjsx%2Fautomapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nestjsx","download_url":"https://codeload.github.com/nestjsx/automapper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246620319,"owners_count":20806750,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automapper","nestjs","typescript"],"created_at":"2024-08-01T17:00:54.294Z","updated_at":"2025-04-10T09:31:35.545Z","avatar_url":"https://github.com/nestjsx.png","language":"TypeScript","readme":"\u003cp align=\"center\"\u003e\u003cimg src=\"https://avatars1.githubusercontent.com/u/43827489?s=400\u0026u=45ac0ac47d40b6d8f277c96bdf00244c10508aef\u0026v=4\"/\u003e\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://badgen.net/travis/nestjsx/automapper\"\u003e\u003cimg src=\"https://badgen.net/travis/nestjsx/automapper\" alt=\"travis\"/\u003e\u003c/a\u003e\n    \u003ca href=\"https://badgen.net/npm/v/nestjsx-automapper\"\u003e\u003cimg src=\"https://badgen.net/npm/v/nestjsx-automapper\" alt=\"npm\"/\u003e\u003c/a\u003e\n    \u003ca href=\"https://badgen.net/npm/dt/nestjsx-automapper\"\u003e\u003cimg src=\"https://badgen.net/npm/dt/nestjsx-automapper\" alt=\"downloads\"/\u003e\u003c/a\u003e\n    \u003ca href=\"https://badgen.net/bundlephobia/minzip/nestjsx-automapper\"\u003e\u003cimg src=\"https://badgen.net/bundlephobia/minzip/nestjsx-automapper\" alt=\"bundlephobia\"/\u003e\u003c/a\u003e\n    \u003ca href=\"https://badgen.net/github/license/nestjsx/automapper\"\u003e\u003cimg src=\"https://badgen.net/github/license/nestjsx/automapper\" alt=\"license\"/\u003e\u003c/a\u003e\n    \u003ca href=\"https://coveralls.io/repos/github/nestjsx/automapper/badge.svg?branch=master\"\u003e\u003cimg src=\"https://coveralls.io/repos/github/nestjsx/automapper/badge.svg?branch=master\" alt=\"coveralls\"/\u003e\u003c/a\u003e\n    \u003ca href=\"https://greenkeeper.io/\"\u003e\u003cimg src=\"https://badges.greenkeeper.io/nestjsx/automapper.svg\" alt=\"Greenkeeper\"/\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003ch1 align=\"center\"\u003eNestJSX Automapper\u003c/h1\u003e\n\u003cp align=\"center\"\u003eA wrapper around \u003ca href=\"https://github.com/nartc/mapper\"\u003e@nartc/automapper\u003c/a\u003e to be used with \u003cstrong\u003eNestJS\u003c/strong\u003e as a \u003ccode\u003eModule\u003c/code\u003e.\u003c/p\u003e\n\n## Announcement\n\n`@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](https://automapperts.netlify.app) for Migration Guide.\n\n## Migrations\n\n#### Migrate to v3\n\n`forRoot()` method will be deprecated soon (still available in v3). Please use `withMapper()` instead.\n\n## Documentations\n\nThis module is a wrapper around `@nartc/automapper` so all usage documentations should be referenced at the link below.\n\nGithub Pages [https://automapper.netlify.com/](https://automapper.netlify.com/)\nGithub Repo [https://github.com/nartc/mapper](https://github.com/nartc/mapper)\n\n## Features\n\n- [x] Mapping between two classes\n- [x] Mapping for nested classes\n- [x] Array/List Mapping\n- [x] Flattening\n- [x] Basic ReverseMap\n- [x] Value Converters\n- [x] Value Resolvers\n- [x] Async\n- [x] Before/After Callback\n- [x] Naming Conventions (PascalCase and camelCase)\n\nContributions are appreciated.\n\n\n## Setup\n```\nnpm i -s nestjsx-automapper\n```\n\nInstalling `nestjsx-automapper` will also install `@nartc/automapper`.\n\n**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.\n\n### Setup\n\n1. Import `AutomapperModule` in `AppModule` and call `.withMapper()` method\n\n```typescript\n@Module({\n  imports: [AutomapperModule.withMapper()],\n})\nexport class AppModule {}\n```\n\n`AutomapperModule.withMapper()` has the following overloads:\n\n```typescript\nstatic withMapper(name?: string, options?: AutoMapperGlobalSettings);\nstatic withMapper(options?: AutoMapperGlobalSettings);\n```\n\n- `name`: Name of the `AutoMapper` instance being created with `withMapper()`. Default to `\"default\"`\n- `options`: Check [AutoMapperGlobalSettings](https://automapper.netlify.app/docs/usages/init/with-global-settings/) for more information\n\n2. `nestjsx-automapper` exposes a `@Profile()` decorator to decorate your `Profile` classes.\n\n```typescript\n@Profile()\nclass UserProfile extends ProfileBase {}\n```\n\n`@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\"`\n\nUsually, `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.\nIf 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).\n\n3. Inject the `AutoMapper` instance in your `Injectable`\n\n```typescript\n@Injectable()\nexport class UserService {\n  constructor(@InjectMapper() private readonly mapper: AutoMapper) {}\n}\n```\n\n`@InjectMapper()` takes in an optional `name` argument which will tell the decorator which `AutoMapper` instance to inject. Default to `\"default\"`\n\n\u003e `InjectMapper` is imported from `nestjsx-automapper`. `AutoMapper` is imported from `@nartc/automapper`\n\n4. Use `AutoMapper` on your models\n\n```typescript\n// ...\nconst result = await newUser.save();\nreturn this.mapper.map(result.toJSON(), UserVm, User);\n```\n","funding_links":["https://github.com/sponsors/nartc"],"categories":["Components \u0026 Libraries","TypeScript","资源"],"sub_categories":["组件和库"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnestjsx%2Fautomapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnestjsx%2Fautomapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnestjsx%2Fautomapper/lists"}