MCPcopy Create free account
hub / github.com/clintonwoo/hackernews-remix-react / fetchComment

Method fetchComment

src/server/database/database.ts:55–81  ·  view source on GitHub ↗
(id: number)

Source from the content-addressed store, hash-verified

53 }
54
55 async fetchComment(id: number): Promise<CommentModel | void> {
56 logger('Fetching comment:', `${HN_API_URL}/item/${id}.json`);
57
58 return get(child(this.db, `item/${id}`))
59 .then((itemSnapshot) => {
60 const item = itemSnapshot.val();
61
62 if (item !== null && !item.deleted && !item.dead) {
63 const comment = new CommentModel({
64 id: item.id,
65 comments: item.kids,
66 creationTime: item.time * 1000,
67 parent: item.parent,
68 submitterId: item.by,
69 text: item.text,
70 });
71
72 this.cache.setComment(comment.id, comment);
73 logger('Created Comment:', item.id);
74
75 return comment;
76 }
77
78 throw item;
79 })
80 .catch((reason) => logger('Fetching comment failed:', reason));
81 }
82
83 async fetchUser(id: string): Promise<UserModel | void> {
84 logger('Fetching user:', `${HN_API_URL}/user/${id}.json`);

Callers 1

getCommentMethod · 0.80

Calls 1

setCommentMethod · 0.80

Tested by

no test coverage detected