mirror of
https://github.com/LibreChat-AI/librechat.ai.git
synced 2026-03-27 18:58:32 +07:00
* docs: enhance API key setup instructions for clarity * docs: update section title for API key setup clarity * docs: add comprehensive guide for OpenAI image generation and editing tools * docs: clarify Stable Diffusion section and update link in Image Generation overview * docs: add Flux cloud generator configuration details and environment variables * fix: Firebase CDN configuration link * docs: enhance fileStrategy section with CDN options and notes * docs: enhance Image Generation section with improved structure and pricing details * docs: add Code Interpreter section with environment variable details and enterprise plan notes * fix: formatting * chore: bump next * fix: correct markdown formatting for artifact example in agents documentation * docs: add deprecation notices for tools, plugins, presets, and enhance image generation section * feat: implement GitHub stats API and update Usage component to fetch stars dynamically * fix: update Docker pulls value in Usage component
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import type { NextApiRequest, NextApiResponse } from 'next'
|
|
import axios from 'axios'
|
|
|
|
type GitHubResponse = {
|
|
stargazers_count: number
|
|
}
|
|
|
|
type ResponseData = {
|
|
stars: number
|
|
error?: string
|
|
}
|
|
|
|
export default async function handler(req: NextApiRequest, res: NextApiResponse<ResponseData>) {
|
|
try {
|
|
// GitHub API endpoint for the LibreChat repository
|
|
const response = await axios.get<GitHubResponse>(
|
|
'https://api.github.com/repos/danny-avila/LibreChat',
|
|
{
|
|
headers: {
|
|
Accept: 'application/vnd.github.v3+json',
|
|
// Use GitHub token if available in environment variables
|
|
...(process.env.GITHUB_TOKEN && {
|
|
Authorization: `token ${process.env.GITHUB_TOKEN}`,
|
|
}),
|
|
},
|
|
},
|
|
)
|
|
|
|
// Cache the response for 1 hour (3600 seconds)
|
|
res.setHeader('Cache-Control', 's-maxage=3600, stale-while-revalidate')
|
|
|
|
// Return the star count
|
|
return res.status(200).json({ stars: response.data.stargazers_count })
|
|
} catch (error) {
|
|
console.error('Error fetching GitHub stats:', error)
|
|
return res.status(500).json({ stars: 0, error: 'Failed to fetch GitHub stats' })
|
|
}
|
|
}
|