{"id":28202351,"url":"https://github.com/mash-up-node/nestjs-contenttype","last_synced_at":"2025-08-17T10:37:00.283Z","repository":{"id":285420463,"uuid":"957880058","full_name":"Mash-Up-Node/NestJS-ContentType","owner":"Mash-Up-Node","description":"Django ContentType like framework for Nest.js","archived":false,"fork":false,"pushed_at":"2025-04-02T11:47:58.000Z","size":327,"stargazers_count":3,"open_issues_count":2,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-05T06:16:56.079Z","etag":null,"topics":["content-type","mashup","nestjs","typeorm","typeorm-extension"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@mashup-node/content-type","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/Mash-Up-Node.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-03-31T09:40:31.000Z","updated_at":"2025-04-23T06:36:44.000Z","dependencies_parsed_at":"2025-05-17T08:00:45.012Z","dependency_job_id":null,"html_url":"https://github.com/Mash-Up-Node/NestJS-ContentType","commit_stats":null,"previous_names":["mash-up-node/nestjs-content-type"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Mash-Up-Node/NestJS-ContentType","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mash-Up-Node%2FNestJS-ContentType","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mash-Up-Node%2FNestJS-ContentType/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mash-Up-Node%2FNestJS-ContentType/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mash-Up-Node%2FNestJS-ContentType/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Mash-Up-Node","download_url":"https://codeload.github.com/Mash-Up-Node/NestJS-ContentType/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mash-Up-Node%2FNestJS-ContentType/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270837405,"owners_count":24654376,"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","status":"online","status_checked_at":"2025-08-17T02:00:09.016Z","response_time":129,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["content-type","mashup","nestjs","typeorm","typeorm-extension"],"created_at":"2025-05-17T00:13:01.102Z","updated_at":"2025-08-17T10:37:00.273Z","avatar_url":"https://github.com/Mash-Up-Node.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nest.js Content Type\n\n![NPM Version](https://img.shields.io/npm/v/@mashup-node/content-type?style=for-the-badge)\n\n[ContentType](https://docs.djangoproject.com/en/5.1/ref/contrib/contenttypes/) implementation in Nest.js + TypeORM with Minimal Changes in previous code base\n\n**[ 이런 장점과 확장성이 있어요! ]**\n\n- 기존 코드베이스의 큰 틀에 대한 수정은 필요 없어요\n- 검색엔진과 연동하기 좋아요\n  - 모델을 메타데이터 단위의 추적이 가능해요\n  - 모델에 대한 검색 대상을 동적으로 결정할 수 있어요\n- Event기반 기능 구현시 더욱 편리한 DX를 제공합니다.\n- Permission 및 Object Permission을 구현할 수 있어요\n- 일반 RDB Relation보다 훨씬 유연한 연관관계를 활용할 수 있어요\n\n## Installation\n\n```text\n# npm\n\nnpm install @mashup-node/content-type\n\n# yarn\n\nyarn add @mashup-node/content-type\n\n# pnpm\n\npnpm add @mashup-node/content-type\n\n```\n\n**[ Maintainers ]**\n\n- [14th 윤준호(Hoplin)](https://github.com/J-Hoplin)\n\n## How to use?\n\n1. TypeORM Module Option 정의의 `entities` 프로퍼티에 아래 두 모델을 추가해주세요\n\n```typescript\nimport { ContentType, GenericRelation } from '@mashup-node/content-type';\n\nexport const databaseSourceOption = {\n  ...\n\n  entities: [\n    (Previous Entity Setting),\n    ContentType,\n    GenericRelation\n  ],\n\n  ...\n};\n\n```\n\n2. ContentType에 등록하고 싶은 Entity에 `@EnrollContentType` 데코레이터를 추가합니다.\n\n```typescript\nimport { EnrollContentType } from '@mashup-node/content-type';\n\n\n@Entity('some_entity')\n@EnrollContentType({ appLabel: 'application', name: 'SomeModel' })\nexport class SomeEntity extends BaseEntity {\n  ...\n}\n\n\n@Entity('other_entity')\n@EnrollContentType()\nexport class OtherEntity extends BaseEntity {\n  ...\n}\n```\n\n3. `ContentTypeModule`과 `ContentTypeService`를 활용해봐요.\n\n`ContentTypeModule`은 TypeORM의 Entity Metadata를 활용하므로 TypeORM Module 이후에 호출되어야 한다는점은 필수에요. 자세한 API는 하단을 참조해주세요.\n\n```typescript\n// Module\n\n@Module({\n  imports: [TypeOrmModule.forRoot(databaseSourceOption), ... , ContentTypeModule],\n})\nexport class AppModule {}\n\n// Service\n\n@Injectable()\nexport class AppService {\n  constructor(\n    private readonly config: ConfigService,\n    private readonly puppeteer: PuppeteerPoolService,\n    private readonly contentType: ContentTypeService,\n  ) {}\n\n  ...\n}\n```\n\n## Decorator: `@EnrollContentType`\n\nTypeORM Entity Class를 Content Type으로 등록한다. 사용방법은 일반 Entity에 대해 데코레이터를 추가합니다.\n\n```typescript\nimport { Entity } from 'typeorm';\n\n@Entity()\n@EnrollContentType()\nclass SomeEntity {}\n```\n\n`@EnrollContentType`의 기본적인 Parameter Type입니다.\n\n- `appLabel`: (Optional) 모델 앱 레이블, 모델 구분 식별자 역할\n  - Default: Entity Name Lowercase\n- `name`: (Optional) 모델 이름\n  - Default: Entity Name\n\n```typescript\nexport interface ContentTypeOptions {\n  appLabel?: string;\n  name?: string;\n}\n```\n\n## APIs: `ContentTypeService`\n\n### getContentType(appLabel: string, model: string): Promise\u003cContentType\u003e\n\n- **Description**: 주어진 app label과 entity name에 대한 ContentType을 가져오거나 생성합니다.\n- **Parameter**:\n  - `appLabel`: 구분자에 해당함\n  - `model`: Entity 이름\n- **Return**: Promise\u003cContentType\u003e\n- **Example**:\n  ```typescript\n  const contentType = await contentTypeService.getContentType('auth', 'User');\n  ```\n\n### getObject(contentType: ContentType, id: string | number): Promise\u003cany\u003e\n\n- **Description**: ContentType과 ID를 통해 object를 가져옵니다.\n- **Parameter**:\n  - `contentType`: ContentType Instance\n  - `id`: object's id. (내부적으로 처리할떄는 String으로만 처리함.)\n- **Return**: Promise\u003cany\u003e\n- **Example**:\n  ```typescript\n  const user = await contentTypeService.getObject(contentType, 1);\n  ```\n\n### createGenericRelation(contentType: ContentType, objectId: string | number, fieldName: string): Promise\u003cGenericRelation\u003e\n\n- **Description**: 객체 간의 연관 관계를 생성합니다. (일반 RDB 연관관계보다 유연함)\n- **Parameter**:\n  - `contentType`: ContentType Instance\n  - `objectId`: related object's id\n  - `fieldName`: related field name\n- **Return**: Promise\u003cGenericRelation\u003e\n- **Example**:\n  ```typescript\n  const relation = await contentTypeService.createGenericRelation(contentType, 1, 'author');\n  ```\n\n### getGenericRelations(contentType: ContentType): Promise\u003cGenericRelation[]\u003e\n\n- **Description**: ContentType에 대한 모든 연관 관계를 가져옵니다.\n- **Parameter**:\n  - `contentType`: ContentType Instance\n- **Return**: Promise\u003cGenericRelation[]\u003e\n- **Example**:\n  ```typescript\n  const relations = await contentTypeService.getGenericRelations(contentType);\n  ```\n\n### deleteGenericRelation(id: number): Promise\u003cvoid\u003e\n\n- **Description**: GenericRelation 삭제합니다.\n- **Parameter**:\n  - `id`: relationId\n- **Return**: Promise\u003cvoid\u003e\n- **Example**:\n  ```typescript\n  await contentTypeService.deleteGenericRelation(1);\n  ```\n\n## License\n\nMIT MashUp Node.js Team. See [LICENSE](./LICENSE) for more detail\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmash-up-node%2Fnestjs-contenttype","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmash-up-node%2Fnestjs-contenttype","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmash-up-node%2Fnestjs-contenttype/lists"}