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
|
BACKEND_PROTOCOL=http
|
||||||
NEXT_PUBLIC_CONTENT_URL=http://127.0.0.1:8000/content/torrent
|
BACKEND_DOMAIN=127.0.0.1
|
||||||
NEXT_PUBLIC_FRAGMENT_URL=http://127.0.0.1:8000/content/audio
|
BACKEND_PORT=8000
|
||||||
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
|
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} */
|
/** @type {import('next').NextConfig} */
|
||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
async rewrites() {
|
async rewrites() {
|
||||||
return process.env.NODE_ENV == "development"
|
return [
|
||||||
? [
|
{
|
||||||
{
|
source: "/api/:path*",
|
||||||
source: "/api/:path*",
|
destination: `${process.env.BACKEND_PROTOCOL}://`+
|
||||||
destination: "http://127.0.0.1:8000/:path*",
|
`${process.env.BACKEND_DOMAIN}:${process.env.BACKEND_PORT}/:path*`,
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
: [];
|
|
||||||
},
|
},
|
||||||
images: {
|
images: {
|
||||||
remotePatterns: [
|
remotePatterns: [
|
||||||
{
|
{
|
||||||
protocol: "http",
|
protocol: process.env.BASE_PROTOCOL,
|
||||||
hostname: "127.0.0.1",
|
hostname: process.env.BASE_DOMAIN,
|
||||||
port: "8000",
|
port: process.env.BASE_PORT,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -11,39 +11,47 @@ export const metadata: Metadata = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default async function Home() {
|
export default async function Home() {
|
||||||
const cards: { [k in SectionType]?: ItemCardType[] | null } = {};
|
const requests = SectionService.sections.map((section) =>
|
||||||
await Promise.all(
|
ItemService.itemsConfiguration[
|
||||||
SectionService.sections.map(async (section) => {
|
SectionService.sectionsConfiguration[section].itemType
|
||||||
cards[section] = await ItemService.itemsConfiguration[
|
].service.GetCards()
|
||||||
SectionService.sectionsConfiguration[section].itemType
|
);
|
||||||
].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 (
|
return (
|
||||||
<>
|
<>
|
||||||
{SectionService.sections.map((section) => (
|
{cards &&
|
||||||
<section key={section}>
|
SectionService.sections.map((section, i) => (
|
||||||
{cards[section] && cards[section].length > 0 && (
|
<section key={section}>
|
||||||
<Section
|
{cards[section] && (
|
||||||
name={
|
<Section
|
||||||
SectionService.sectionsConfiguration[section]
|
name={
|
||||||
.popularSubsectionName
|
SectionService.sectionsConfiguration[section]
|
||||||
}
|
.popularSubsectionName
|
||||||
link={
|
}
|
||||||
SectionService.isSection(section) ? `/${section}` : undefined
|
link={
|
||||||
}
|
SectionService.isSection(section) ? `/${section}` : undefined
|
||||||
invite_text={
|
}
|
||||||
SectionService.sectionsConfiguration[section].sectionInviteText
|
invite_text={
|
||||||
}
|
SectionService.sectionsConfiguration[section]
|
||||||
>
|
.sectionInviteText
|
||||||
{cards[section].map((card) => (
|
}
|
||||||
<ItemCard key={card.id} card={card} />
|
>
|
||||||
))}
|
{cards[section]?.map((card) => (
|
||||||
</Section>
|
<ItemCard key={card.id} card={card} />
|
||||||
)}
|
))}
|
||||||
</section>
|
</Section>
|
||||||
))}
|
)}
|
||||||
|
</section>
|
||||||
|
))}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ export const Img = ({
|
|||||||
<Image
|
<Image
|
||||||
className={className}
|
className={className}
|
||||||
src={
|
src={
|
||||||
|
"" +
|
||||||
|
process.env.NEXT_PUBLIC_BASE_URL +
|
||||||
|
process.env.NEXT_PUBLIC_API_PATTERN +
|
||||||
(preview
|
(preview
|
||||||
? process.env.NEXT_PUBLIC_COVER_PREVIEW_URL
|
? process.env.NEXT_PUBLIC_COVER_PREVIEW_URL
|
||||||
: process.env.NEXT_PUBLIC_COVER_FULL_URL) +
|
: process.env.NEXT_PUBLIC_COVER_FULL_URL) +
|
||||||
|
|||||||
@@ -34,25 +34,31 @@ export abstract class HTTPService {
|
|||||||
schema: Z,
|
schema: Z,
|
||||||
options?: RequestOptions
|
options?: RequestOptions
|
||||||
) {
|
) {
|
||||||
return await fetch(process.env.NEXT_PUBLIC_BASE_URL + url, {
|
return await fetch(
|
||||||
method: method,
|
"" +
|
||||||
headers: {
|
process.env.NEXT_PUBLIC_BASE_URL +
|
||||||
accept: "application/json",
|
process.env.NEXT_PUBLIC_API_PATTERN +
|
||||||
...((options?.stringify ?? true) != true
|
url,
|
||||||
? {}
|
{
|
||||||
: { "Content-Type": "application/json" }),
|
method: method,
|
||||||
Authorization: "Bearer " + UserService.GetToken(),
|
headers: {
|
||||||
...options?.headers,
|
accept: "application/json",
|
||||||
},
|
...((options?.stringify ?? true) != true
|
||||||
body:
|
? {}
|
||||||
(options?.stringify ?? true) != true
|
: { "Content-Type": "application/json" }),
|
||||||
? (options?.body as BodyInit)
|
Authorization: "Bearer " + UserService.GetToken(),
|
||||||
: JSON.stringify(
|
...options?.headers,
|
||||||
this.deepUndefinedToNull(options?.body as object | undefined)
|
},
|
||||||
),
|
body:
|
||||||
cache: options?.cache ?? options?.next ? undefined : "no-cache",
|
(options?.stringify ?? true) != true
|
||||||
next: options?.next ?? {},
|
? (options?.body as BodyInit)
|
||||||
})
|
: JSON.stringify(
|
||||||
|
this.deepUndefinedToNull(options?.body as object | undefined)
|
||||||
|
),
|
||||||
|
cache: options?.cache ?? options?.next ? undefined : "no-cache",
|
||||||
|
next: options?.next ?? {},
|
||||||
|
}
|
||||||
|
)
|
||||||
.then((r) => {
|
.then((r) => {
|
||||||
if (r && r.ok) return r;
|
if (r && r.ok) return r;
|
||||||
else throw Error("Response ok = false");
|
else throw Error("Response ok = false");
|
||||||
|
|||||||
@@ -62,6 +62,9 @@ export const ItemFragment = ({
|
|||||||
controlsList="nodownload"
|
controlsList="nodownload"
|
||||||
typeof="audio/mpeg"
|
typeof="audio/mpeg"
|
||||||
src={
|
src={
|
||||||
|
"" +
|
||||||
|
process.env.NEXT_PUBLIC_BASE_URL +
|
||||||
|
process.env.NEXT_PUBLIC_API_PATTERN +
|
||||||
process.env.NEXT_PUBLIC_FRAGMENT_URL +
|
process.env.NEXT_PUBLIC_FRAGMENT_URL +
|
||||||
"/" +
|
"/" +
|
||||||
(watched_fragment ?? "")
|
(watched_fragment ?? "")
|
||||||
|
|||||||
@@ -67,7 +67,12 @@ export const ItemTorrent = ({
|
|||||||
<div className="flex flex-col items-center">
|
<div className="flex flex-col items-center">
|
||||||
<Link
|
<Link
|
||||||
href={
|
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(
|
className={clsx(
|
||||||
"p-4 bg-ac0 text-fg1 text-2xl rounded-lg",
|
"p-4 bg-ac0 text-fg1 text-2xl rounded-lg",
|
||||||
|
|||||||
Reference in New Issue
Block a user