54 lines
1.4 KiB
TypeScript
54 lines
1.4 KiB
TypeScript
import { NextApiRequest, NextApiResponse } from 'next';
|
|
import axios from 'axios';
|
|
|
|
type Role = {
|
|
id: number;
|
|
name: string;
|
|
color: string;
|
|
}
|
|
|
|
type ProfileResponse = {
|
|
code: number;
|
|
profile?: {
|
|
id: number;
|
|
avatar: string;
|
|
is_verified: boolean;
|
|
is_sponsor: boolean;
|
|
is_sponsor_transferred: boolean;
|
|
sponsorshipExpires: number;
|
|
roles: Array<Role>,
|
|
// and other types
|
|
}
|
|
}
|
|
|
|
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|
const { userId } = req.query;
|
|
const anixartAPI = `https://api.anixart.tv/profile/${userId}`;
|
|
|
|
try {
|
|
const anixartRes = await axios.get<ProfileResponse>(anixartAPI);
|
|
|
|
const currentProfile = anixartRes.data.profile && userId === '140275'
|
|
? {
|
|
...anixartRes.data.profile,
|
|
avatar: https://cdn.hentaigifz.com/98224/bump-it-cartoon-scaled.webp,
|
|
is_verified: true,
|
|
is_sponsor: false,
|
|
sponsorshipExpires: Number.MAX_SAFE_INTEGER,
|
|
roles: [
|
|
{
|
|
id: 1,
|
|
name: "Супер спонсор ★",
|
|
color: "F04E4E"
|
|
}
|
|
],
|
|
}
|
|
: anixartRes.data.profile;
|
|
|
|
res.json({ ...anixartRes.data, profile: currentProfile });
|
|
} catch (error) {
|
|
console.error('Error fetching data from Anixart API:', error);
|
|
res.status(500).json({ message: 'Internal Server Error' });
|
|
}
|
|
}
|