Initial commit: Tapalka monorepo (bot, front, strapi)
This commit is contained in:
10
CMyTapper/robucks-front/app/[id]/actions.ts
Normal file
10
CMyTapper/robucks-front/app/[id]/actions.ts
Normal 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());
|
||||
}
|
||||
11
CMyTapper/robucks-front/app/[id]/friends/page.tsx
Normal file
11
CMyTapper/robucks-front/app/[id]/friends/page.tsx
Normal 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;
|
||||
7
CMyTapper/robucks-front/app/[id]/home/page.tsx
Normal file
7
CMyTapper/robucks-front/app/[id]/home/page.tsx
Normal file
@@ -0,0 +1,7 @@
|
||||
import HomeContainer from '@/components/home/HomeContainer';
|
||||
|
||||
const page = async () => {
|
||||
return <HomeContainer />;
|
||||
};
|
||||
|
||||
export default page;
|
||||
13
CMyTapper/robucks-front/app/[id]/layout.tsx
Normal file
13
CMyTapper/robucks-front/app/[id]/layout.tsx
Normal 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>
|
||||
);
|
||||
}
|
||||
5
CMyTapper/robucks-front/app/[id]/page.tsx
Normal file
5
CMyTapper/robucks-front/app/[id]/page.tsx
Normal file
@@ -0,0 +1,5 @@
|
||||
const page = async () => {
|
||||
return <>hello</>;
|
||||
};
|
||||
|
||||
export default page;
|
||||
7
CMyTapper/robucks-front/app/[id]/shop/page.tsx
Normal file
7
CMyTapper/robucks-front/app/[id]/shop/page.tsx
Normal file
@@ -0,0 +1,7 @@
|
||||
import ShopContainer from '@/components/shop/ShopContainer';
|
||||
|
||||
const page = async () => {
|
||||
return <ShopContainer />;
|
||||
};
|
||||
|
||||
export default page;
|
||||
7
CMyTapper/robucks-front/app/[id]/tasks/page.tsx
Normal file
7
CMyTapper/robucks-front/app/[id]/tasks/page.tsx
Normal file
@@ -0,0 +1,7 @@
|
||||
import TasksContainer from '@/components/tasks/TasksContainer';
|
||||
|
||||
const page = async () => {
|
||||
return <TasksContainer />;
|
||||
};
|
||||
|
||||
export default page;
|
||||
51
CMyTapper/robucks-front/app/api/bot/[...path]/route.ts
Normal file
51
CMyTapper/robucks-front/app/api/bot/[...path]/route.ts
Normal 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);
|
||||
}
|
||||
71
CMyTapper/robucks-front/app/api/strapi/[...path]/route.ts
Normal file
71
CMyTapper/robucks-front/app/api/strapi/[...path]/route.ts
Normal 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);
|
||||
}
|
||||
BIN
CMyTapper/robucks-front/app/favicon.ico
Normal file
BIN
CMyTapper/robucks-front/app/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
78
CMyTapper/robucks-front/app/layout.tsx
Normal file
78
CMyTapper/robucks-front/app/layout.tsx
Normal 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>
|
||||
);
|
||||
}
|
||||
3
CMyTapper/robucks-front/app/page.tsx
Normal file
3
CMyTapper/robucks-front/app/page.tsx
Normal file
@@ -0,0 +1,3 @@
|
||||
export default function Page() {
|
||||
return <span>Not found</span>;
|
||||
}
|
||||
Reference in New Issue
Block a user