Skip to content

Commit ec15451

Browse files
committed
Introduce interface for RemoteConfigEncoder
1 parent 5e03f97 commit ec15451

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/features/projects/data/GitHubProjectDataSource.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ import {
1111
GitHubRepositoryRef
1212
} from "../domain"
1313
import RemoteConfig from "../domain/RemoteConfig"
14-
import RemoteConfigEncoder from "../domain/RemoteConfigEncoder"
14+
import { IRemoteConfigEncoder } from "../domain/RemoteConfigEncoder"
1515

1616
export default class GitHubProjectDataSource implements IProjectDataSource {
1717
private readonly repositoryDataSource: IGitHubRepositoryDataSource
1818
private readonly repositoryNameSuffix: string
1919
private readonly encryptionService: IEncryptionService
20-
private readonly remoteConfigEncoder: RemoteConfigEncoder
20+
private readonly remoteConfigEncoder: IRemoteConfigEncoder
2121

2222
constructor(config: {
2323
repositoryDataSource: IGitHubRepositoryDataSource
2424
repositoryNameSuffix: string
2525
encryptionService: IEncryptionService
26-
remoteConfigEncoder: RemoteConfigEncoder
26+
remoteConfigEncoder: IRemoteConfigEncoder
2727
}) {
2828
this.repositoryDataSource = config.repositoryDataSource
2929
this.repositoryNameSuffix = config.repositoryNameSuffix

src/features/projects/domain/RemoteConfigEncoder.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
import { IEncryptionService } from "@/features/encrypt/EncryptionService";
22
import RemoteConfig, { RemoteConfigSchema } from "./RemoteConfig";
33

4+
export interface IRemoteConfigEncoder {
5+
encode(remoteConfig: RemoteConfig): string;
6+
decode(encodedString: string): RemoteConfig;
7+
}
8+
49
/**
510
* Encodes and decodes remote configs.
611
*
712
* The remote config is first stringified to JSON, then encrypted, and finally encoded in base64.
813
*
914
* At the receiving end, the encoded string is first decoded from base64, then decrypted, and finally parsed as JSON.
1015
*/
11-
export default class RemoteConfigEncoder {
16+
export default class RemoteConfigEncoder implements IRemoteConfigEncoder {
1217
private readonly encryptionService: IEncryptionService;
1318

1419
constructor(encryptionService: IEncryptionService) {

0 commit comments

Comments
 (0)