id-codec.service.ts 647 B

12345678910111213141516171819202122
  1. import { Injectable } from '@nestjs/common';
  2. import { ID } from '../../../../shared/shared-types';
  3. import { ConfigService } from '../../config/config.service';
  4. import { IdCodec } from './id-codec';
  5. @Injectable()
  6. export class IdCodecService {
  7. private idCodec: IdCodec;
  8. constructor(configService: ConfigService) {
  9. this.idCodec = new IdCodec(configService.entityIdStrategy);
  10. }
  11. encode(target: any, transformKeys?: string[]): string {
  12. return this.idCodec.encode(target, transformKeys);
  13. }
  14. decode(target: any, transformKeys?: string[]): ID {
  15. return this.idCodec.decode(target, transformKeys);
  16. }
  17. }