This repository has been archived on 2026-11-17. You can view files and clone it, but cannot push or open issues or pull requests.
gitgram-ai/gitgram/mobile/services/trendingService.ts
caelum0x 64fbe9f474 feat: round-3 deep product build-out (69 gaps closed, all 7 products green)
Deep-audit + build-out across all products to fully-usable state; all typecheck clean.

- gitgram-web (99): wire Store feature to real endpoints, close 9 gaps
- gitgram-backend (100): close 8 flow gaps, document infra-provisioning items
- gitgram-mobile (90): fix API base-URL/path mismatch (404s) + copy proximity
  components into components/proximity wired to real screens; 15 gaps, +react-native-svg
- aitm-core (95): wire natural-language CLI flow end-to-end; 11 gaps
- aitm-api (97): fix teams metadata runtime bug; copy a2a-js server/client/grpc
  into src/a2a and wire A2A route; crates.io package search; 8 gaps
- aitm-mcp (100): fix A2A client/server card mismatch; 9 gaps
- aitm-website (95): build missing docs routes; 9 gaps

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-28 13:54:57 +03:00

116 lines
2.6 KiB
TypeScript

import api from './api';
export interface TrendingPost {
id: string;
content: string;
mediaUrl?: string;
mediaType?: string;
likesCount: number;
commentsCount: number;
viewsCount: number;
createdAt: string;
user: {
id: string;
username: string;
avatar?: string;
verified: boolean;
};
}
export interface TrendingHashtag {
id: string;
name: string;
count?: number;
_count?: {
posts: number;
};
}
export interface TrendingUser {
id: string;
username: string;
avatar?: string;
verified: boolean;
bio?: string;
_count: {
followers: number;
posts: number;
};
}
export const trendingService = {
/**
* Get trending posts
* Uses /api/v1/posts/trending endpoint
* Backend may return array directly or { posts: [...] }
*/
getTrendingPosts: async (
timeframe: 'today' | 'week' | 'month' = 'week',
page = 1,
limit = 20
): Promise<{ posts: TrendingPost[]; hasMore: boolean }> => {
const response = await api.get('/posts/trending', {
params: { timeframe, page, limit },
});
// Normalize response - backend may return array directly or { posts: [...] }
const data = response.data;
if (Array.isArray(data)) {
return { posts: data, hasMore: data.length >= limit };
}
return { posts: data.posts || [], hasMore: data.hasMore ?? false };
},
/**
* Get trending hashtags
* Uses /api/v1/tags/trending endpoint
*/
getTrendingHashtags: async (
limit = 50
): Promise<TrendingHashtag[]> => {
const response = await api.get('/tags/trending', {
params: { limit },
});
return response.data;
},
/**
* Get trending/popular users
* Uses /api/v1/popular/users endpoint
*/
getTrendingUsers: async (
limit = 20
): Promise<{ users: TrendingUser[] }> => {
const response = await api.get('/popular/users', {
params: { limit },
});
return response.data;
},
/**
* Get popular posts (alternative trending)
* Uses /api/v1/popular/posts endpoint
*/
getPopularPosts: async (
limit = 20,
offset = 0
): Promise<{ posts: TrendingPost[]; hasMore: boolean }> => {
const response = await api.get('/popular/posts', {
params: { limit, offset },
});
return response.data;
},
/**
* Get popular hashtags (alternative trending)
* Uses /api/v1/popular/hashtags endpoint
*/
getPopularHashtags: async (
limit = 10
): Promise<{ hashtags: TrendingHashtag[] }> => {
const response = await api.get('/popular/hashtags', {
params: { limit },
});
return response.data;
},
};