Skip to content

Commit ffedf0a

Browse files
committed
linter warnings regarding usage of any
1 parent abbdc77 commit ffedf0a

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

infrastructure/service/lemmyContentAggregatorService.ts

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,43 @@
11
import Post from "../../domain/service/contentAggregatorService/post";
22
import ContentAggregatorService from "../../domain/service/contentAggregatorService/contentAggregatorService";
33

4+
interface LemmyPostAuthor {
5+
display_name: string;
6+
name: string;
7+
}
8+
9+
interface LemmyPostData {
10+
featured_community: boolean;
11+
featured_local: boolean;
12+
name: string;
13+
ap_id: string;
14+
body: string;
15+
published: string;
16+
}
17+
18+
interface LemmyPost {
19+
creator: LemmyPostAuthor;
20+
post: LemmyPostData;
21+
}
22+
23+
interface LemmyApiResponse {
24+
posts: LemmyPost[];
25+
}
26+
427
export default class LemmyContentAggregatorService implements ContentAggregatorService {
528
private feedUrl = "https://lemmy.pt/api/v3/post/list?community_name=devpt&limit=10&page=1&sort=New";
629

730
async fetchLastPosts(): Promise<Post[]> {
8-
let unpinnedPosts = [];
31+
let unpinnedPosts: Post[] = [];
932

1033
try {
1134
const response = await fetch(this.feedUrl);
12-
13-
const data = await response.json();
35+
const data: LemmyApiResponse = await response.json();
1436

1537
unpinnedPosts = data.posts
16-
.filter((item: any) => !item.post.featured_community && !item.post.featured_local)
38+
.filter((item: LemmyPost) => !item.post.featured_community && !item.post.featured_local)
1739
.map(
18-
(item: any) =>
40+
(item: LemmyPost) =>
1941
new Post({
2042
authorName: item.creator.display_name || item.creator.name,
2143
title: item.post.name,

0 commit comments

Comments
 (0)