npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@mashup-node/content-type

v0.4.2

Published

A Django-like Content Type framework for Node.js with TypeORM

Downloads

5

Readme

Nest.js Content Type

NPM Version

ContentType implementation in Nest.js + TypeORM with Minimal Changes in previous code base

[ 이런 장점과 확장성이 있어요! ]

  • 기존 코드베이스의 큰 틀에 대한 수정은 필요 없어요
  • 검색엔진과 연동하기 좋아요
    • 모델을 메타데이터 단위의 추적이 가능해요
    • 모델에 대한 검색 대상을 동적으로 결정할 수 있어요
  • Event기반 기능 구현시 더욱 편리한 DX를 제공합니다.
  • Permission 및 Object Permission을 구현할 수 있어요
  • 일반 RDB Relation보다 훨씬 유연한 연관관계를 활용할 수 있어요

Installation

# npm

npm install @mashup-node/content-type

# yarn

yarn add @mashup-node/content-type

# pnpm

pnpm add @mashup-node/content-type

[ Maintainers ]

How to use?

  1. TypeORM Module Option 정의의 entities 프로퍼티에 아래 두 모델을 추가해주세요
import { ContentType, GenericRelation } from '@mashup-node/content-type';

export const databaseSourceOption = {
  ...

  entities: [
    (Previous Entity Setting),
    ContentType,
    GenericRelation
  ],

  ...
};
  1. ContentType에 등록하고 싶은 Entity에 @EnrollContentType 데코레이터를 추가합니다.
import { EnrollContentType } from '@mashup-node/content-type';


@Entity('some_entity')
@EnrollContentType({ appLabel: 'application', name: 'SomeModel' })
export class SomeEntity extends BaseEntity {
  ...
}


@Entity('other_entity')
@EnrollContentType()
export class OtherEntity extends BaseEntity {
  ...
}
  1. ContentTypeModuleContentTypeService를 활용해봐요.

ContentTypeModule은 TypeORM의 Entity Metadata를 활용하므로 TypeORM Module 이후에 호출되어야 한다는점은 필수에요. 자세한 API는 하단을 참조해주세요.

// Module

@Module({
  imports: [TypeOrmModule.forRoot(databaseSourceOption), ... , ContentTypeModule],
})
export class AppModule {}

// Service

@Injectable()
export class AppService {
  constructor(
    private readonly config: ConfigService,
    private readonly puppeteer: PuppeteerPoolService,
    private readonly contentType: ContentTypeService,
  ) {}

  ...
}

Decorator: @EnrollContentType

TypeORM Entity Class를 Content Type으로 등록한다. 사용방법은 일반 Entity에 대해 데코레이터를 추가합니다.

import { Entity } from 'typeorm';

@Entity()
@EnrollContentType()
class SomeEntity {}

@EnrollContentType의 기본적인 Parameter Type입니다.

  • appLabel: (Optional) 모델 앱 레이블, 모델 구분 식별자 역할
    • Default: Entity Name Lowercase
  • name: (Optional) 모델 이름
    • Default: Entity Name
export interface ContentTypeOptions {
  appLabel?: string;
  name?: string;
}

APIs: ContentTypeService

getContentType(appLabel: string, model: string): Promise

  • Description: 주어진 app label과 entity name에 대한 ContentType을 가져오거나 생성합니다.
  • Parameter:
    • appLabel: 구분자에 해당함
    • model: Entity 이름
  • Return: Promise
  • Example:
    const contentType = await contentTypeService.getContentType('auth', 'User');

getObject(contentType: ContentType, id: string | number): Promise

  • Description: ContentType과 ID를 통해 object를 가져옵니다.
  • Parameter:
    • contentType: ContentType Instance
    • id: object's id. (내부적으로 처리할떄는 String으로만 처리함.)
  • Return: Promise
  • Example:
    const user = await contentTypeService.getObject(contentType, 1);

createGenericRelation(contentType: ContentType, objectId: string | number, fieldName: string): Promise

  • Description: 객체 간의 연관 관계를 생성합니다. (일반 RDB 연관관계보다 유연함)
  • Parameter:
    • contentType: ContentType Instance
    • objectId: related object's id
    • fieldName: related field name
  • Return: Promise
  • Example:
    const relation = await contentTypeService.createGenericRelation(contentType, 1, 'author');

getGenericRelations(contentType: ContentType): Promise<GenericRelation[]>

  • Description: ContentType에 대한 모든 연관 관계를 가져옵니다.
  • Parameter:
    • contentType: ContentType Instance
  • Return: Promise<GenericRelation[]>
  • Example:
    const relations = await contentTypeService.getGenericRelations(contentType);

deleteGenericRelation(id: number): Promise

  • Description: GenericRelation 삭제합니다.
  • Parameter:
    • id: relationId
  • Return: Promise
  • Example:
    await contentTypeService.deleteGenericRelation(1);

License

MIT MashUp Node.js Team. See LICENSE for more detail