Playing around with some Tan packages

This commit is contained in:
2024-06-19 01:11:03 -04:00
parent ad64899de4
commit 5655e22075
9 changed files with 5813 additions and 0 deletions

1
.env.production Normal file
View File

@@ -0,0 +1 @@
BASE_RSS_FEED=https://example.com

29
.eslintrc.js Normal file
View File

@@ -0,0 +1,29 @@
module.exports = {
env: {
browser: true,
es2021: true,
},
extends: [
'airbnb-base',
'plugin:sonarjs/recommended',
'plugin:react-hooks/recommended',
'plugin:@tanstack/eslint-plugin-query/recommended'
],
overrides: [
{
env: {
node: true,
},
files: ['.eslintrc.{js,cjs}'],
parserOptions: {
sourceType: 'script',
},
},
],
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
rules: {},
ignorePatterns: ['**/libs/*.js', 'node_modules/**', 'env/**'],
};

5663
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

50
package.json Normal file
View File

@@ -0,0 +1,50 @@
{
"name": "public-plex-watchlist",
"version": "0.0.1",
"description": "Turn your Plex Watchlist RSS feed into an interface non-Plex folks can search and filter.",
"main": "src/index.js",
"source": "src/index.html",
"scripts": {
"start": "parcel",
"build": "parcel build",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/averymd/public-plex-watchlist.git"
},
"keywords": [
"plex",
"reactjs"
],
"author": "Melissa Avery-Weir",
"license": "Unlicense",
"bugs": {
"url": "https://github.com/averymd/public-plex-watchlist/issues"
},
"homepage": "https://github.com/averymd/public-plex-watchlist#readme",
"dependencies": {
"@tanstack/react-query": "^5.45.1",
"@tanstack/react-table": "^8.17.3",
"axios": "^1.7.2",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"rss-parser": "^3.13.0"
},
"devDependencies": {
"@tanstack/eslint-plugin-query": "^5.43.1",
"buffer": "^6.0.3",
"eslint": "^9.5.0",
"eslint-plugin-react-hooks": "^5.1.0-rc-1434af3d22-20240618",
"events": "^3.3.0",
"https-browserify": "^1.0.0",
"parcel": "^2.12.0",
"process": "^0.11.10",
"punycode": "^1.4.1",
"stream-browserify": "^3.0.0",
"stream-http": "^3.2.0",
"string_decoder": "^1.3.0",
"timers-browserify": "^2.0.12",
"url": "^0.11.3"
}
}

12
src/App.js Normal file
View File

@@ -0,0 +1,12 @@
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import Wishlist from './components/Wishlist';
export default function App() {
const queryClient = new QueryClient();
return (
<QueryClientProvider client={queryClient}>
<Wishlist />
</QueryClientProvider>
);
}

7
src/api/plexApi.js Normal file
View File

@@ -0,0 +1,7 @@
import axios from 'axios';
import Parser from 'rss-parser';
export async function fetchPlexWatchlistFeed(feed) {
let rssParser = new Parser();
return rssParser.parseURL(feed);
}

View File

@@ -0,0 +1,22 @@
import { useQuery, useQueryClient } from '@tanstack/react-query';
import { fetchPlexWatchlistFeed } from '../../api/plexApi';
import { useState } from 'react';
export default function Wishlist() {
const [feedItems, setFeedItems] = useState([]);
const [currentFeedUrl, setCurrentFeedUrl] = useState(
process.env.BASE_RSS_FEED
);
const { isPending, isError, data, error, isFetching, isSuccess } = useQuery({
queryKey: ['wishlistItems', currentFeedUrl],
queryFn: () => fetchPlexWatchlistFeed(currentFeedUrl),
});
return (
<div>
<div>{isFetching ? 'Updating...' : ''}</div>
<div>{isSuccess ? data.title : 'nothing'}</div>
</div>
);
}

15
src/index.html Normal file
View File

@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="index.js"></script>
</body>
</html>

14
src/index.js Normal file
View File

@@ -0,0 +1,14 @@
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
// import './styles.css';
import App from './App';
import { useQueryClient } from '@tanstack/react-query';
const root = createRoot(document.getElementById('root'));
root.render(
<StrictMode>
<App />
</StrictMode>
);