How to use the class-transformer.Expose function in class-transformer

To help you get started, we’ve selected a few class-transformer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dilame / instagram-private-api / src / models / media.ts View on Github external
get webLink() {
    return `https://www.instagram.com/p/${this.code}/`;
  }

  // Backward compatibility
  @Expose()
  get account() {
    return this.user;
  }

  @Expose()
  get takenAt() {
    return this.taken_at * 1000;
  }

  @Expose()
  get images() {
    return this.image_versions2;
  }

  @Expose()
  get videos() {
    return this.video_versions;
  }
}
github ZhiXiao-Lin / nestify / server / src / common / entities / role.entity.ts View on Github external
@OneToMany((type) => User, (user) => user.role)
    users: User[];

    static readonly sheetsMap: object = {
        角色: {
            map: 'roles',
            handleType: ExcelHandleType.ARRAY,
            cellsMap: { ID: 'id', 名称: 'name', 标识: 'token', 描述: 'desc', 排序: 'sort' }
        }
    };

    static create(target: Object) {
        return plainToClass(Role, target);
    }

    @Expose()
    get isSuperAdmin(): boolean {
        return this.token === 'superAdmin';
    }
}
github ZhiXiao-Lin / nestify / server / src / common / entities / authority.entity.ts View on Github external
@TreeParent() parent: Authority;

    @ManyToMany((type) => Role, (role) => role.authorities)
    roles: Role[];

    @Expose()
    get label(): string {
        return this.name;
    }

    @Expose()
    get title(): string {
        return this.name;
    }

    @Expose()
    get key(): string {
        return this.id;
    }

    @Expose()
    get value(): string {
        return this.id;
    }

    static readonly sheetsMap: object = {
        权限: {
            map: 'authorities',
            handleType: ExcelHandleType.ARRAY,
            cellsMap: {
                ID: 'id',
                名称: 'name',
github ZhiXiao-Lin / nestify / server / src / common / entities / authority.entity.ts View on Github external
@Expose()
    get label(): string {
        return this.name;
    }

    @Expose()
    get title(): string {
        return this.name;
    }

    @Expose()
    get key(): string {
        return this.id;
    }

    @Expose()
    get value(): string {
        return this.id;
    }

    static readonly sheetsMap: object = {
        权限: {
            map: 'authorities',
            handleType: ExcelHandleType.ARRAY,
            cellsMap: {
                ID: 'id',
                名称: 'name',
                标识: 'token',
                描述: 'desc',
                排序: 'sort',
                PID: 'parent'
            }
github ZhiXiao-Lin / nestify / server / src / common / entities / category.entity.ts View on Github external
@TreeChildren() children: Category[];

	@TreeParent() parent: Category;

	@Expose()
	get title(): string {
		return this.name;
	}

	@Expose()
	get key(): string {
		return this.id;
	}

	@Expose()
	get value(): string {
		return this.id;
	}

	static readonly sheetsMap: object = {
		分类: {
			map: 'categorys',
			handleType: ExcelHandleType.ARRAY,
			cellsMap: { ID: 'id', 名称: 'name', 排序: 'sort', PID: 'parent' }
		}
	};

	static create(target: object) {
		return plainToClass(Category, target);
	}
}
github ZhiXiao-Lin / nestify / server / src / common / entities / authority.entity.ts View on Github external
@Column({ type: 'simple-json', default: {}, comment: '扩展信息' })
    ex_info: any;

    @TreeChildren() children: Authority[];

    @TreeParent() parent: Authority;

    @ManyToMany((type) => Role, (role) => role.authorities)
    roles: Role[];

    @Expose()
    get label(): string {
        return this.name;
    }

    @Expose()
    get title(): string {
        return this.name;
    }

    @Expose()
    get key(): string {
        return this.id;
    }

    @Expose()
    get value(): string {
        return this.id;
    }

    static readonly sheetsMap: object = {
        权限: {
github ZhiXiao-Lin / nestify / server / src / common / entities / carousel.entity.ts View on Github external
@Column({ type: 'simple-json', default: {}, comment: '扩展信息' })
    ex_info: any;

    static readonly sheetsMap: object = {
        轮播: {
            map: 'carousels',
            handleType: ExcelHandleType.ARRAY,
            cellsMap: { 标识: 'token' }
        }
    };

    static create(target: object): Carousel | Carousel[] {
        return plainToClass(Carousel, target);
    }

    @Expose()
    get carousels() {
        return !this.ex_info.carousels
            ? []
            : this.ex_info.carousels.map((item) => {
                const newItem = { ...item };
                newItem.image = Base.getFullPath(item.image);
                return newItem;
            });
    }
}
github ZhiXiao-Lin / nestify / server / src / common / entities / user.entity.ts View on Github external
@OneToMany((type) => Flow, (flow) => flow.executor)
    executeFlows: Flow[];

    @OneToMany((type) => Detail, (detail) => detail.user)
    details: Detail[];

    static create(target: Object) {
        return plainToClass(User, target);
    }

    @Expose()
    get avatarPath(): string {
        return Base.getFullPath(this.avatar);
    }

    @Expose()
    get isSuperAdmin(): boolean {
        return !!this.role && this.role.token === 'superAdmin';
    }

    @Expose()
    get isVolunteer(): boolean {
        return !!this.role && this.role.token === 'volunteer';
    }

    @BeforeInsert()
    async beforeInsert() {
        const salt = await bcrypt.genSalt(10);
        this.password = await bcrypt.hash(this.password || '12345678', salt);
    }

    @BeforeUpdate()
github dilame / instagram-private-api / src / models / media.ts View on Github external
@Expose()
  get account() {
    return this.user;
  }

  @Expose()
  get takenAt() {
    return this.taken_at * 1000;
  }

  @Expose()
  get images() {
    return this.image_versions2;
  }

  @Expose()
  get videos() {
    return this.video_versions;
  }
}
github ZhiXiao-Lin / nestify / server / src / common / entities / content.entity.ts View on Github external
}
                }
            }
        }
    };

    static create(target: object): Content | Content[] {
        return plainToClass(Content, target);
    }

    @Expose()
    get thumbnailPath(): string {
        return Base.getFullPath(this.thumbnail);
    }

    @Expose()
    get videoPath(): string {
        return Base.getFullPath(this.video);
    }

    @BeforeInsert()
    async beforeInsert() {
        if (!this.publish_at) {
            this.publish_at = moment().format('YYYY-MM-DD HH:mm:ss');
        }
        const text = extractionTextInHtml(this.text);
        this.summary = textInterception(text, 120);
    }

    @BeforeUpdate()
    async beforeUpdate() {
        const text = extractionTextInHtml(this.text);