Skip to content

Commit

Permalink
Implement the parser for third-party.json
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinyaigeek committed Sep 4, 2024
1 parent f13502e commit d25602c
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import type { Result } from "option-t/esm/PlainResult";
import type { FileIOInfrastructureInterface } from "../../infrastructure/file-io/file-io.interface";
import type { FilePathInfrastructureInterface } from "../../infrastructure/file-path/file-path.interface";
import { parseThirdPartyPublishContentsListJson } from "./parse-third-party-publish-contents-list-json";
import type { ThirdPartyPublishContent } from "./third-party-publish.entity";

export class ThirdPartyPublishContentRepository {
Expand All @@ -8,17 +10,22 @@ export class ThirdPartyPublishContentRepository {
private filePathInfrastructure: FilePathInfrastructureInterface,
) {}

public async getThirdPartyPublishContents(): Promise<ThirdPartyPublishContent> {
public async getThirdPartyPublishContents(): Promise<
Result<ThirdPartyPublishContent[], Error>
> {
const thirdPartyPublishContentsListPath =
this.filePathInfrastructure.resolve(
process.cwd(),
"src/articles/third-pirty.json",
);

const thirdPartyPublichContentsList = JSON.parse(
await this.fileIOInfrastructure.readFile(
thirdPartyPublishContentsListPath,
),
);
const thirdPartyPublichContentsList =
parseThirdPartyPublishContentsListJson(
await this.fileIOInfrastructure.readFile(
thirdPartyPublishContentsListPath,
),
);

return thirdPartyPublichContentsList;
}
}

0 comments on commit d25602c

Please sign in to comment.