ekyc

Electronic KYC process with uploading ID document using OAuth 2.1 (experimental)
Log | Files | Refs | README | LICENSE

admin.ts (636B)


      1 import { AdminRepository } from "#core/application/id_document/admin_repository.ts";
      2 import { Admin } from "#core/domain/admin.ts";
      3 import { UUID } from "#core/domain/uuid.ts";
      4 import { EntityNotFound } from "#core/application/repository_error.ts";
      5 
      6 export class ConfigAdminRepository implements AdminRepository {
      7   constructor(private readonly path: string) {
      8   }
      9 
     10   async find(id: UUID): Promise<Admin> {
     11     const exists = (JSON.parse(await Deno.readTextFile(this.path)) as string[])
     12       .some(uuid => uuid === id.toString())
     13 
     14     if (exists) {
     15       return new Admin(id);
     16     }
     17 
     18     throw new EntityNotFound(id.toString());
     19   }
     20 }