Initial commit: Tapalka monorepo (bot, front, strapi)

This commit is contained in:
2026-05-21 11:54:44 +07:00
commit 9ec9485940
208 changed files with 58314 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
'use server';
import { cookies } from 'next/headers';
export async function setNewToken(token: string) {
cookies().set('token', token);
}
export async function setNowDate() {
cookies().set('dateLifetimeJwt', new Date().toDateString());
}

View File

@@ -0,0 +1,11 @@
import FriendsContainer from '@/components/friends/FriendsContiner';
import { ConfigBotApi } from '@/api/config-bot.api';
const page = async () => {
const configBotApi = ConfigBotApi.getInstance();
const botLink = await configBotApi.getBotLink();
return <FriendsContainer botLink={botLink.link} />;
};
export default page;

View File

@@ -0,0 +1,7 @@
import HomeContainer from '@/components/home/HomeContainer';
const page = async () => {
return <HomeContainer />;
};
export default page;

View File

@@ -0,0 +1,13 @@
import Wrapper from '@/components/ui/wrapper/Wrapper';
import { Providers } from '@/components/providers/Providers';
import { PropsWithChildren } from 'react';
import { Params } from 'next/dist/shared/lib/router/utils/route-matcher';
export default function RootLayout({ children, params }: PropsWithChildren & { params: Params }) {
const id = decodeURI(params.id);
return (
<Wrapper>
<Providers id={id}>{children}</Providers>
</Wrapper>
);
}

View File

@@ -0,0 +1,5 @@
const page = async () => {
return <>hello</>;
};
export default page;

View File

@@ -0,0 +1,7 @@
import ShopContainer from '@/components/shop/ShopContainer';
const page = async () => {
return <ShopContainer />;
};
export default page;

View File

@@ -0,0 +1,7 @@
import TasksContainer from '@/components/tasks/TasksContainer';
const page = async () => {
return <TasksContainer />;
};
export default page;

View File

@@ -0,0 +1,51 @@
import { NextRequest, NextResponse } from 'next/server';
const BOT_API_URL = process.env.BOT_API_INTERNAL || 'http://127.0.0.1:3001';
async function proxyRequest(req: NextRequest, params: { path: string[] }) {
const path = params.path.join('/');
const url = `${BOT_API_URL}/${path}`;
try {
const headers: Record<string, string> = {
'Content-Type': 'application/json',
};
const fetchOptions: RequestInit = {
method: req.method,
headers,
};
if (req.method !== 'GET' && req.method !== 'HEAD') {
const body = await req.text();
if (body) {
fetchOptions.body = body;
}
}
const response = await fetch(url, fetchOptions);
const data = await response.json();
return NextResponse.json(data, { status: response.status });
} catch (error) {
console.error('Bot proxy error:', error);
return NextResponse.json(
{ error: 'Bot API unavailable' },
{ status: 502 }
);
}
}
export async function GET(
req: NextRequest,
{ params }: { params: { path: string[] } }
) {
return proxyRequest(req, params);
}
export async function POST(
req: NextRequest,
{ params }: { params: { path: string[] } }
) {
return proxyRequest(req, params);
}

View File

@@ -0,0 +1,71 @@
import { NextRequest, NextResponse } from 'next/server';
const STRAPI_URL = process.env.STRAPI_INTERNAL || 'http://127.0.0.1:1337/api';
async function proxyRequest(req: NextRequest, params: { path: string[] }) {
const path = params.path.join('/');
const searchParams = req.nextUrl.searchParams.toString();
const url = `${STRAPI_URL}/${path}${searchParams ? `?${searchParams}` : ''}`;
try {
const headers: Record<string, string> = {
'Content-Type': 'application/json',
};
const authHeader = req.headers.get('Authorization');
if (authHeader) {
headers['Authorization'] = authHeader;
}
const fetchOptions: RequestInit = {
method: req.method,
headers,
};
if (req.method !== 'GET' && req.method !== 'HEAD') {
const body = await req.text();
if (body) {
fetchOptions.body = body;
}
}
const response = await fetch(url, fetchOptions);
const data = await response.json();
return NextResponse.json(data, { status: response.status });
} catch (error) {
console.error('Strapi proxy error:', error);
return NextResponse.json(
{ error: 'Strapi API unavailable' },
{ status: 502 }
);
}
}
export async function GET(
req: NextRequest,
{ params }: { params: { path: string[] } }
) {
return proxyRequest(req, params);
}
export async function POST(
req: NextRequest,
{ params }: { params: { path: string[] } }
) {
return proxyRequest(req, params);
}
export async function PUT(
req: NextRequest,
{ params }: { params: { path: string[] } }
) {
return proxyRequest(req, params);
}
export async function DELETE(
req: NextRequest,
{ params }: { params: { path: string[] } }
) {
return proxyRequest(req, params);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View File

@@ -0,0 +1,78 @@
import type { Metadata } from 'next';
import Script from 'next/script';
import localFont from 'next/font/local';
import { Manrope } from 'next/font/google';
import '../public/globals.css';
import { PropsWithChildren } from 'react';
import { Params } from 'next/dist/shared/lib/router/utils/route-matcher';
const manrope = Manrope({
weight: ['200', '300', '400', '500', '600', '700'],
style: ['normal'],
subsets: ['latin'],
variable: '--font-manrope',
});
const clashFont = localFont({
src: [
{
path: '../public/fonts/ClashDisplay-Bold.otf',
weight: '800',
style: 'normal',
},
{
path: '../public/fonts/ClashDisplay-Extralight.otf',
weight: '100',
style: 'normal',
},
{
path: '../public/fonts/ClashDisplay-Light.otf',
weight: '200',
style: 'normal',
},
{
path: '../public/fonts/ClashDisplay-Regular.otf',
weight: '400',
style: 'normal',
},
{
path: '../public/fonts/ClashDisplay-Semibold.otf',
weight: '600',
style: 'normal',
},
{
path: '../public/fonts/ClashDisplay-Medium.otf',
weight: '500',
style: 'normal',
},
],
variable: '--font-clash',
});
export const metadata: Metadata = {
title: 'Robucks clicker',
description: 'Robucks clicker',
};
export default async function RootLayout({
children,
params,
}: PropsWithChildren & { params: Params }) {
return (
<html lang='ru'>
<head>
<Script
src='https://telegram.org/js/telegram-web-app.js'
strategy='beforeInteractive'
/>
</head>
<body
className={`${clashFont.className} ${manrope.variable}`}
suppressHydrationWarning={true}
>
{children}
</body>
</html>
);
}

View File

@@ -0,0 +1,3 @@
export default function Page() {
return <span>Not found</span>;
}