Skip to content

Commit

Permalink
stored api in lib
Browse files Browse the repository at this point in the history
  • Loading branch information
ShivaBhattacharjee committed Aug 25, 2023
1 parent 10e97cc commit 6351854
Show file tree
Hide file tree
Showing 14 changed files with 25 additions and 21 deletions.
3 changes: 2 additions & 1 deletion src/app/movie/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import ServerError from '@/components/error/ServerError';
import VerticalCards from '@/components/shared/cards/VerticalCards';
import AnimeApi from '@/lib/animetrixapi';
import React from 'react'
const getAnimeMovies = async () => {
try {
const response = await fetch("https://animetrix-api.vercel.app/meta/anilist/MOVIE?perPage=24");
const response = await fetch(`${AnimeApi}/MOVIE?perPage=24`);
const data = await response.json();
return data.results;
} catch (error) {
Expand Down
5 changes: 3 additions & 2 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import UpcomingSeason from '@/components/shared/upcomingSeason/UpcomingSeason';
import { RandomAnimeCard } from "@/components/shared/RandomAnimeCard"
import { UpcomingSeasonLoading } from '@/components/loading/UpcomingSeasonLoading';
import RandomAnimeLoading from '@/components/loading/RandomAnimeLoading';
import AnimeApi from '@/lib/animetrixapi';
const getTrendingAnime = async () => {
try {
const response = await fetch("https://animetrix-api.vercel.app/meta/anilist/trending?perPage=20");
const response = await fetch(`${AnimeApi}/trending?perPage=20`);
const data = await response.json();
return data.results;
} catch (error) {
Expand All @@ -20,7 +21,7 @@ const getTrendingAnime = async () => {
};
const getPopularAnime = async () => {
try {
const response = await fetch("https://animetrix-api.vercel.app/meta/anilist/popular?perPage=20");
const response = await fetch(`${AnimeApi}/popular?perPage=20`);
const data = await response.json();
return data.results;
} catch (error) {
Expand Down
3 changes: 2 additions & 1 deletion src/app/popular/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import ServerError from '@/components/error/ServerError';
import VerticalCards from '@/components/shared/cards/VerticalCards';
import AnimeApi from '@/lib/animetrixapi';
import React from 'react'
const getPopularAnime = async () => {
try {
const response = await fetch("https://animetrix-api.vercel.app/meta/anilist/popular?perPage=24");
const response = await fetch(`${AnimeApi}/popular?perPage=24`);
const data = await response.json();
return data.results;
} catch (error) {
Expand Down
7 changes: 3 additions & 4 deletions src/components/shared/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ import React from 'react';

const socialMediaLinks = [
{
icon: <Github className=' scale-125' />,
icon: <Github className='scale-125' />,
url: 'https://github.com/ShivaBhattacharjee/AnimeTrix-next',
},
{
icon: <Instagram className=' scale-125' />,
icon: <Instagram className='scale-125' />,
url: 'https://www.instagram.com/animetrix.200/',
},
// Add more social media links as needed
];

const Footer = () => {
Expand All @@ -19,7 +18,7 @@ const Footer = () => {
<div className='flex flex-col gap-7 justify-between items-center'>
<h1 className='text-3xl font-bold'>AnimeTrix</h1>
<p className='text-sm text-center font-semibold m-auto max-w-4xl'>
AnimeTrix is not affiliated with or endorsed by any of the anime studios behind the creation of the anime presented on this site. This website is only an user interface presenting/linking various self-hosted files across the internet by other third-party providers for easy access. AnimeTrix never downloads the video from any source provider, link will be returned from the response hence it is completely not subjected to DMCA compliant.
AnimeTrix is not affiliated with or endorsed by any of the anime studios behind the creation of the anime presented on this site. This website is only an user interface presenting/linking various self-hosted files across the internet by other third-party providers for easy access. AnimeTrix never downloads the video from any source provider, link will be returned from the response hence it is completely not subjected to DMCA compliant.
</p>
<div className="flex gap-6 pb-6">
{socialMediaLinks.map((link, index) => (
Expand Down
8 changes: 4 additions & 4 deletions src/components/shared/RandomAnimeCard.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import React from 'react';
import ReloadFunc from '../error/ReloadFunc';
import Image from 'next/image';
import Link from 'next/link';
import AnimeApi from '@/lib/animetrixapi';
const getRandomAnime = async () => {
try {
const response = await fetch("https://animetrix-api.vercel.app/meta/anilist/random-anime", {
const response = await fetch(`${AnimeApi}/random-anime`, {
cache: "no-store"
});

const data = await response.json(); // Parse the response JSON
const data = await response.json();
return data;
} catch (error) {
console.error("Error fetching random anime:", error);
return null; // Return null on error
return null;
}
};

Expand Down
3 changes: 1 addition & 2 deletions src/components/shared/Slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import React, { useRef, useState } from 'react';
import { Swiper, SwiperSlide } from 'swiper/react';
import { Autoplay } from 'swiper/modules';
import 'swiper/css';
import './styles.css';
import './SliderStyles.css';
import { ArrowLeft, ArrowRight } from 'lucide-react';
import Image from 'next/image';
import ReloadFunc from '../error/ReloadFunc';
import Link from 'next/link';
import Anime from '@/types/animetypes';
Expand Down
File renamed without changes.
6 changes: 1 addition & 5 deletions src/components/shared/cards/EpisodeLists.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
"use client"
import React, { useState, useMemo } from 'react';
import { Frown } from "lucide-react";
interface Anime {
image: string;
number: number;
title: string;
}
import Anime from '@/types/animetypes';

interface EpisodeListsProps {
listData: Anime[];
Expand Down
3 changes: 2 additions & 1 deletion src/components/shared/cards/RelationCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
import React from 'react'
import Link from 'next/link';
import Anime from '@/types/animetypes';
import AnimeApi from '@/lib/animetrixapi';

interface Props {
id: number;
}
export default async function RelationCard({ id }: Props) {
const getRelationDetails = async () => {
try {
const response = await fetch(`https://animetrix-api.vercel.app/meta/anilist/info/${id}`);
const response = await fetch(`${AnimeApi}/info/${id}`);
const data = await response.json();
return data.relations;
} catch (error) {
Expand Down
3 changes: 2 additions & 1 deletion src/components/shared/upcomingSeason/UpcomingSeason.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import React from 'react';
import UpcomingSeasonCard from './UpcomingSeasonCard';
import Anime from '@/types/animetypes';
import AnimeApi from '@/lib/animetrixapi';
const getCurrentYear = () => {
return new Date().getFullYear();
};

const getAnimeData = async (season: string): Promise<Anime[]> => {
try {
const response = await fetch(`https://animetrix-api.vercel.app/meta/anilist/advanced-search?season=${season}&&year=${getCurrentYear()}`);
const response = await fetch(`${AnimeApi}/advanced-search?season=${season}&&year=${getCurrentYear()}`);
const data = await response.json();
return data.results;
} catch (error) {
Expand Down
2 changes: 2 additions & 0 deletions src/lib/animetrixapi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const AnimeApi = `https://animetrix-api.vercel.app/meta/anilist`
export default AnimeApi
1 change: 1 addition & 0 deletions src/middleware/VerifyEmail.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// will be updated later
1 change: 1 addition & 0 deletions src/models/user.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// will be updated later
1 change: 1 addition & 0 deletions src/types/animetypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ export default interface Anime {
totalEpisodes: number;
status: string;
relationType: string;
number: number;
}

0 comments on commit 6351854

Please sign in to comment.