Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preview main #203

Merged
11 commits merged into from
May 2, 2024
Merged
32 changes: 23 additions & 9 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,30 +1,44 @@
# Backend Server URL
# Backend Server URL [NOT OPTIONAL]
# Description: Base URL for the primary backend server used for API requests to fetch anime data, metadata, and other related information.
# Example: VITE_BACKEND_URL="https://api.consumet.org/"
# Example: VITE_BACKEND_URL="https://public-miruro-consumet-api.vercel.app/"
VITE_BACKEND_URL="https://public-miruro-consumet-api.vercel.app/"

# Episode Skip Times URL
# Episode Skip Times URL [OPTIONAL]
# Description: URL for fetching episode skip times to help users skip intros, outros, and recaps.
# Example & Current Setting: VITE_SKIP_TIMES="https://api.aniskip.com/"
VITE_SKIP_TIMES="https://api.aniskip.com/"

# Proxy Server URL
# Proxy Server URL [OPTIONAL]
# Description: URL of the proxy server used to circumvent CORS issues or when making requests to external services that do not support CORS.
# Example: VITE_PROXY_URL="https://corsproxy.io/"
VITE_PROXY_URL="https://corsproxy.io/"

# Server Port
# API Key [OPTIONAL]
# Description: The API key used for authenticating requests to secured endpoints. This key ensures that only authorized users and applications can access specific API functions.
# To generate a secure API key, you can use the command: openssl rand -base64 32
# Example: VITE_API_KEY="your_secret_api_key_here"
VITE_API_KEY=""

# Server Port [OPTIONAL]
# Description: The port number on which the server will listen. Important for server configuration in both development and production environments.
# Example & Default: PORT=5173
VITE_PORT=5173

# Google Analytics [OPTIONAL]
# Description: Google Analytics Measurement ID used for tracking website analytics and user interactions.
# This ID is provided by Google Analytics and is used to initialize the analytics library in the frontend application.
VITE_GA_MEASUREMENT_ID=""

# The following Variables are Optional.

# AniList Configuration [OPTIONAL]
# Description: Configuration for connecting to AniList API.
# Example & Current Setting: VITE_DEPLOY_PLATFORM="VERCEL"
VITE_DEPLOY_PLATFORM="VERCEL"

VITE_CLIENT_ID=
# Description: AniList client ID for authentication.
VITE_CLIENT_ID=""

# Description: AniList client secret for authentication.
VITE_CLIENT_SECRET=""

VITE_REDIRECT_URI=""
# Description: Redirect URI for authentication flow with AniList.
VITE_REDIRECT_URI=""
4 changes: 3 additions & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ body:
label: Which version was acting up?
description: Pick the app version that was giving you grief.
options:
- 0.4.4
- 0.5.2
- 0.5.1
- 0.5.0
- 0.4.3
- 0.4.2
- 0.4.1
Expand Down
136 changes: 31 additions & 105 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,40 +1,32 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

# Dependency directories
node_modules/
jspm_packages/
.pnpm-store/

# Build outputs
# Vite and Build outputs
dist/
dist-ssr/
build/
temp/
out/
*.local
.temp/

# Bun
.bun/

# TypeScript cache
*.tsbuildinfo

# Compiled binary addons (node-gyp)
build/Release/

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea/
.vscode/
*.sublime-workspace
*.sublime-project
*.sw?
*.swo
*.swn
*.swp
*.bak
*.orig

# Operating System generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Expand All @@ -45,98 +37,32 @@ Thumbs.db
package-lock.json
yarn.lock
pnpm-lock.yaml
bun.lockb

# Compiled binary addons (node-gyp)
build/Release/

# dotenv environment variables file
# dotenv environment variables files
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

# PyCharm
*.pyc

# JetBrains IDEs (IntelliJ, PyCharm, etc)
*.iml
*.ipr
*.iws
.idea/

# Visual Studio Code
.vscode/*
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/settings.json

# Visual Studio
*.suo
*.ntvs*
*.njsproj
*.sln

# Eclipse
.classpath
.project
.settings/

# Vim swap files
*.sw?

# Backup files
*.bak

# Tern project files
.tern-project

# Temporary files
*~
*.tmp

# TypeScript cache
*.tsbuildinfo

# Yarn Integrity file
.yarn-integrity

# Next.js build output
.next/

# Nuxt.js build output
.nuxt/

# VuePress build output
.vuepress/dist/

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Storybook build outputs
storybook-static/

# Parcel cache
# Caches and logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
.cache/

# ESLint cache
.eslintcache

# Stylelint cache
.stylelintcache

# Temporary folders
tmp/
temp/

#bun.lockb
bun.lockb
# Temporary files
*.tmp
*~
*.bak
*.sw?
*.swo
*.swn
*.swp
*.orig
27 changes: 20 additions & 7 deletions api/exchange-token.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios from 'axios';
import type { VercelRequest, VercelResponse } from '@vercel/node';

export default async (req: VercelRequest, res: VercelResponse) => {
async (req: VercelRequest, res: VercelResponse) => {
if (req.method !== 'POST') {
res.status(405).send('Method Not Allowed');
return;
Expand Down Expand Up @@ -35,10 +35,23 @@ export default async (req: VercelRequest, res: VercelResponse) => {
} else {
throw new Error('Access token not found in the response');
}
} catch (error) {
res.status(500).json({
error: 'Failed to exchange token',
details: error.response?.data || error.message,
});
} catch (error: unknown) {
// First, check if it's an instance of Error
if (error instanceof Error) {
// Now you can safely read the message property
const message = error.message;
// If it's an axios error, it may have a response object
const details = axios.isAxiosError(error) && error.response ? error.response.data : message;
res.status(500).json({
error: 'Failed to exchange token',
details,
});
} else {
// If it's not an Error object, handle it as a generic error
res.status(500).json({
error: 'Failed to exchange token',
details: 'An unknown error occurred',
});
}
}
};
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "miruro_no_kuon",
"private": true,
"version": "0.4.3",
"version": "0.5.2",
"type": "module",
"scripts": {
"dev": "vite --host",
Expand Down
4 changes: 3 additions & 1 deletion server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,7 @@ function getLocalIpAddress() {
// Starting the server
app.listen(PORT, () => {
const ipAddress = getLocalIpAddress();
console.log(`Server is running at:\n- Localhost: http://localhost:${PORT}\n- Local IP: http://${ipAddress}:${PORT}`);
console.log(
`Server is running at:\n- Localhost: http://localhost:${PORT}\n- Local IP: http://${ipAddress}:${PORT}`,
);
});
4 changes: 3 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ function App() {
const measurementId = import.meta.env.VITE_GA_MEASUREMENT_ID;

useEffect(() => {
ReactGA.initialize(measurementId);
if (measurementId) {
ReactGA.initialize(measurementId);
}
}, [measurementId]);

return (
Expand Down
2 changes: 2 additions & 0 deletions src/client/authService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,14 @@ const GET_USER_ANIME_LIST = gql`
entries {
media {
id
format
title {
romaji
english
}
coverImage {
large
color
}
status
episodes
Expand Down
4 changes: 2 additions & 2 deletions src/components/Cards/CardItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import styled from 'styled-components';
import { Link } from 'react-router-dom';
import { SkeletonCard, StatusIndicator, type Anime } from '../../index'; // Adjust the import path to correctly point to your index.ts location
import { FaPlay } from 'react-icons/fa'; // For the play icon
import { TbCardsFilled } from 'react-icons/tb';
import { TbCards } from 'react-icons/tb';
import { FaStar, FaCalendarAlt } from 'react-icons/fa';

const StyledCardWrapper = styled(Link)`
Expand Down Expand Up @@ -257,7 +257,7 @@ export const CardItem: React.FC<{ anime: Anime }> = ({ anime }) => {
)}
{(anime.totalEpisodes || anime.episodes) && (
<>
<TbCardsFilled />
<TbCards />
{anime.totalEpisodes || anime.episodes}
</>
)}
Expand Down
4 changes: 2 additions & 2 deletions src/components/Home/HomeCarousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Swiper, SwiperSlide } from 'swiper/react';
import 'swiper/swiper-bundle.css';
import { useNavigate } from 'react-router-dom';
import { SkeletonSlide, Anime } from '../../index';
import { TbCardsFilled } from 'react-icons/tb';
import { TbCards } from 'react-icons/tb';
import { FaStar } from 'react-icons/fa';
import { FaClock } from 'react-icons/fa6';

Expand Down Expand Up @@ -311,7 +311,7 @@ export const HomeCarousel: FC<HomeCarouselProps> = ({
{type && <SlideInfoItem>{type}</SlideInfoItem>}
{totalEpisodes && (
<SlideInfoItem>
<TbCardsFilled />
<TbCards />
{totalEpisodes}
</SlideInfoItem>
)}
Expand Down
5 changes: 2 additions & 3 deletions src/components/Home/HomeSideBar.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { useEffect, useState } from 'react';
import styled from 'styled-components';
import { Link } from 'react-router-dom'; // Assuming you're using React Router for navigation
import { TbCardsFilled } from 'react-icons/tb';
import { TbCards } from 'react-icons/tb';
import { FaStar, FaCalendarAlt } from 'react-icons/fa';
import { Anime, StatusIndicator } from '../../index';


const SidebarStyled = styled.div`
transition: 0.2s ease-in-out;
margin: 0;
Expand Down Expand Up @@ -142,7 +141,7 @@ export const HomeSideBar: React.FC<{ animeData: Anime[] }> = ({
anime.totalEpisodes !== 0 &&
anime.totalEpisodes !== 0 && (
<>
<TbCardsFilled /> {anime.currentEpisode}
<TbCards /> {anime.currentEpisode}
{' / '}
{anime.totalEpisodes}
</>
Expand Down
4 changes: 2 additions & 2 deletions src/components/Navigation/DropSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import styled from 'styled-components';
import { useNavigate } from 'react-router-dom';
import { Anime } from '../../index';
import { FaArrowRight, FaStar } from 'react-icons/fa';
import { TbCardsFilled } from 'react-icons/tb';
import { TbCards } from 'react-icons/tb';
import { BsArrowUpSquare, BsArrowDownSquare } from 'react-icons/bs';
import { PiKeyReturn } from 'react-icons/pi';

Expand Down Expand Up @@ -224,7 +224,7 @@ export const DropDownSearch: React.FC<Props> = ({
<Details $isSelected={index === selectedIndex}>
<span>&nbsp;{result.type}</span>
<span>&nbsp;&nbsp;</span>
<TbCardsFilled color='#' />
<TbCards color='#' />
<span>&nbsp;</span>
<span>{result.totalEpisodes || 'N/A'}&nbsp;</span>
<FaStar color='#' />
Expand Down
Loading
Loading