mirror of
https://github.com/StepanovPlaton/torrent_frontend.git
synced 2026-04-03 12:20:48 +04:00
Configuration
This commit is contained in:
6
.env
Normal file
6
.env
Normal file
@@ -0,0 +1,6 @@
|
||||
NEXT_PUBLIC_API_PATTERN=/api
|
||||
|
||||
NEXT_PUBLIC_CONTENT_URL=/content/torrent
|
||||
NEXT_PUBLIC_FRAGMENT_URL=/content/audio
|
||||
NEXT_PUBLIC_COVER_FULL_URL=/content/images/cover/full_size
|
||||
NEXT_PUBLIC_COVER_PREVIEW_URL=/content/images/cover/preview
|
||||
@@ -1,5 +1,9 @@
|
||||
NEXT_PUBLIC_BASE_URL=http://127.0.0.1:3000/api
|
||||
NEXT_PUBLIC_CONTENT_URL=http://127.0.0.1:8000/content/torrent
|
||||
NEXT_PUBLIC_FRAGMENT_URL=http://127.0.0.1:8000/content/audio
|
||||
NEXT_PUBLIC_COVER_FULL_URL=http://127.0.0.1:8000/content/images/cover/full_size
|
||||
NEXT_PUBLIC_COVER_PREVIEW_URL=http://127.0.0.1:8000/content/images/cover/preview
|
||||
BACKEND_PROTOCOL=http
|
||||
BACKEND_DOMAIN=127.0.0.1
|
||||
BACKEND_PORT=8000
|
||||
|
||||
BASE_PROTOCOL=http
|
||||
BASE_DOMAIN=127.0.0.1
|
||||
BASE_PORT=3000
|
||||
|
||||
NEXT_PUBLIC_BASE_URL=http://127.0.0.1:3000
|
||||
@@ -1,21 +1,20 @@
|
||||
/** @type {import('next').NextConfig} */
|
||||
const nextConfig = {
|
||||
async rewrites() {
|
||||
return process.env.NODE_ENV == "development"
|
||||
? [
|
||||
return [
|
||||
{
|
||||
source: "/api/:path*",
|
||||
destination: "http://127.0.0.1:8000/:path*",
|
||||
},
|
||||
destination: `${process.env.BACKEND_PROTOCOL}://`+
|
||||
`${process.env.BACKEND_DOMAIN}:${process.env.BACKEND_PORT}/:path*`,
|
||||
}
|
||||
]
|
||||
: [];
|
||||
},
|
||||
images: {
|
||||
remotePatterns: [
|
||||
{
|
||||
protocol: "http",
|
||||
hostname: "127.0.0.1",
|
||||
port: "8000",
|
||||
protocol: process.env.BASE_PROTOCOL,
|
||||
hostname: process.env.BASE_DOMAIN,
|
||||
port: process.env.BASE_PORT,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -11,20 +11,27 @@ export const metadata: Metadata = {
|
||||
};
|
||||
|
||||
export default async function Home() {
|
||||
const cards: { [k in SectionType]?: ItemCardType[] | null } = {};
|
||||
await Promise.all(
|
||||
SectionService.sections.map(async (section) => {
|
||||
cards[section] = await ItemService.itemsConfiguration[
|
||||
const requests = SectionService.sections.map((section) =>
|
||||
ItemService.itemsConfiguration[
|
||||
SectionService.sectionsConfiguration[section].itemType
|
||||
].service.GetCards();
|
||||
})
|
||||
].service.GetCards()
|
||||
);
|
||||
const data = await Promise.all(requests);
|
||||
|
||||
const cards = await SectionService.sections.reduce(
|
||||
(cards, section, i) => ({
|
||||
...cards,
|
||||
[section]: data[i],
|
||||
}),
|
||||
{} as { [k in SectionType]: ItemCardType[] | null }
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
{SectionService.sections.map((section) => (
|
||||
{cards &&
|
||||
SectionService.sections.map((section, i) => (
|
||||
<section key={section}>
|
||||
{cards[section] && cards[section].length > 0 && (
|
||||
{cards[section] && (
|
||||
<Section
|
||||
name={
|
||||
SectionService.sectionsConfiguration[section]
|
||||
@@ -34,10 +41,11 @@ export default async function Home() {
|
||||
SectionService.isSection(section) ? `/${section}` : undefined
|
||||
}
|
||||
invite_text={
|
||||
SectionService.sectionsConfiguration[section].sectionInviteText
|
||||
SectionService.sectionsConfiguration[section]
|
||||
.sectionInviteText
|
||||
}
|
||||
>
|
||||
{cards[section].map((card) => (
|
||||
{cards[section]?.map((card) => (
|
||||
<ItemCard key={card.id} card={card} />
|
||||
))}
|
||||
</Section>
|
||||
|
||||
@@ -21,6 +21,9 @@ export const Img = ({
|
||||
<Image
|
||||
className={className}
|
||||
src={
|
||||
"" +
|
||||
process.env.NEXT_PUBLIC_BASE_URL +
|
||||
process.env.NEXT_PUBLIC_API_PATTERN +
|
||||
(preview
|
||||
? process.env.NEXT_PUBLIC_COVER_PREVIEW_URL
|
||||
: process.env.NEXT_PUBLIC_COVER_FULL_URL) +
|
||||
|
||||
@@ -34,7 +34,12 @@ export abstract class HTTPService {
|
||||
schema: Z,
|
||||
options?: RequestOptions
|
||||
) {
|
||||
return await fetch(process.env.NEXT_PUBLIC_BASE_URL + url, {
|
||||
return await fetch(
|
||||
"" +
|
||||
process.env.NEXT_PUBLIC_BASE_URL +
|
||||
process.env.NEXT_PUBLIC_API_PATTERN +
|
||||
url,
|
||||
{
|
||||
method: method,
|
||||
headers: {
|
||||
accept: "application/json",
|
||||
@@ -52,7 +57,8 @@ export abstract class HTTPService {
|
||||
),
|
||||
cache: options?.cache ?? options?.next ? undefined : "no-cache",
|
||||
next: options?.next ?? {},
|
||||
})
|
||||
}
|
||||
)
|
||||
.then((r) => {
|
||||
if (r && r.ok) return r;
|
||||
else throw Error("Response ok = false");
|
||||
|
||||
@@ -62,6 +62,9 @@ export const ItemFragment = ({
|
||||
controlsList="nodownload"
|
||||
typeof="audio/mpeg"
|
||||
src={
|
||||
"" +
|
||||
process.env.NEXT_PUBLIC_BASE_URL +
|
||||
process.env.NEXT_PUBLIC_API_PATTERN +
|
||||
process.env.NEXT_PUBLIC_FRAGMENT_URL +
|
||||
"/" +
|
||||
(watched_fragment ?? "")
|
||||
|
||||
@@ -67,7 +67,12 @@ export const ItemTorrent = ({
|
||||
<div className="flex flex-col items-center">
|
||||
<Link
|
||||
href={
|
||||
process.env.NEXT_PUBLIC_CONTENT_URL + "/" + watched_torrent_file
|
||||
"" +
|
||||
process.env.NEXT_PUBLIC_BASE_URL +
|
||||
process.env.NEXT_PUBLIC_API_PATTERN +
|
||||
process.env.NEXT_PUBLIC_CONTENT_URL +
|
||||
"/" +
|
||||
watched_torrent_file
|
||||
}
|
||||
className={clsx(
|
||||
"p-4 bg-ac0 text-fg1 text-2xl rounded-lg",
|
||||
|
||||
Reference in New Issue
Block a user