Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Check code formatting
uses: creyD/prettier_action@v4.3
with:
prettier_options: "--check ./client/**/*.{js,jsx,ts,tsx,css,scss,json,md} ./server/**/*.{ts,json,md}"
prettier_options: "--check ./peersync/client/**/*.{js,jsx,ts,tsx,css,scss,json,md} ./peersync/server/**/*.{ts,json,md}"
dry: True


Expand All @@ -39,28 +39,31 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'

- name: Install root dependencies
working-directory: ./peersync
run: pnpm install

- name: Install client dependencies
working-directory: ./client
working-directory: ./peersync/client
run: pnpm install

- name: Lint client
working-directory: ./client
working-directory: ./peersync/client
run: pnpm lint

- name: Build client
working-directory: ./client
working-directory: ./peersync/client
run: pnpm build

- name: Install server dependencies
working-directory: ./server
working-directory: ./peersync/server
run: pnpm install

- name: Lint server
working-directory: ./server
working-directory: ./peersync/server
run: pnpm lint

- name: Build server
working-directory: ./server
working-directory: ./peersync/server
run: pnpm build
18 changes: 18 additions & 0 deletions peersync/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Dependencies
**/node_modules
**/.pnpm

# Build outputs
**/dist
**/.next
**/build

# Cache
**/.cache
**/.eslintcache

# Environment files
**/.env*

# Lock files
**/pnpm-lock.yaml
7 changes: 7 additions & 0 deletions peersync/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"semi": true,
"trailingComma": "es5",
"singleQuote": true,
"tabWidth": 2,
"useTabs": false
}
2 changes: 1 addition & 1 deletion peersync/client/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
"hooks": "@/hooks"
},
"iconLibrary": "lucide"
}
}
2 changes: 1 addition & 1 deletion peersync/client/next.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { NextConfig } from "next";
import type { NextConfig } from 'next';

const nextConfig: NextConfig = {
/* config options here */
Expand Down
1 change: 1 addition & 0 deletions peersync/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"@radix-ui/react-slot": "^1.1.1",
"@radix-ui/react-toast": "^1.2.4",
"@upstash/redis": "^1.34.3",
"@vercel/analytics": "^1.4.1",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"downloadjs": "^1.4.7",
Expand Down
34 changes: 34 additions & 0 deletions peersync/client/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 12 additions & 10 deletions peersync/client/src/app/api/sessions/create/route.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { createSession } from "../../../../lib/session";
import { NextResponse } from "next/server";
import { createSession } from '../../../../lib/session';
import { NextResponse } from 'next/server';

export async function POST() {
try{
const sessionId = await createSession();
return NextResponse.json({ sessionId }, { status: 200 });
} catch {
return NextResponse.json({ error: "Failed to create session" }, { status: 500 });
}

}
try {
const sessionId = await createSession();
return NextResponse.json({ sessionId }, { status: 200 });
} catch {
return NextResponse.json(
{ error: 'Failed to create session' },
{ status: 500 }
);
}
}
29 changes: 16 additions & 13 deletions peersync/client/src/app/api/sessions/delete/[sessionId]/route.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { NextRequest, NextResponse } from "next/server";
import { deleteSession } from "@/lib/session";
import { NextRequest, NextResponse } from 'next/server';
import { deleteSession } from '@/lib/session';

export async function DELETE(request: NextRequest) {
const sessionId = request.nextUrl.pathname.split('/').pop();
if(!sessionId){
return NextResponse.json({ message: "Invalid session" }, { status: 404 });
}
try{
await deleteSession(sessionId);
return NextResponse.json({ message: "Session deleted" }, { status: 200 });
} catch {
return NextResponse.json({ message: "Failed to delete session" }, { status: 500 });
}
}
const sessionId = request.nextUrl.pathname.split('/').pop();
if (!sessionId) {
return NextResponse.json({ message: 'Invalid session' }, { status: 404 });
}
try {
await deleteSession(sessionId);
return NextResponse.json({ message: 'Session deleted' }, { status: 200 });
} catch {
return NextResponse.json(
{ message: 'Failed to delete session' },
{ status: 500 }
);
}
}
64 changes: 38 additions & 26 deletions peersync/client/src/app/api/sessions/validate/[sessionId]/route.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,41 @@
import { NextResponse, NextRequest } from "next/server";
import { getSession,deleteSession } from "../../../../../lib/session";
import { NextResponse, NextRequest } from 'next/server';
import { getSession, deleteSession } from '../../../../../lib/session';

export async function GET(request: NextRequest) {
try{
const sessionId = request.nextUrl.pathname.split('/').pop();
if (!sessionId) {
return NextResponse.json({ valid: false, message: "Invalid session" }, { status: 404 });
}
const session = await getSession(sessionId);
if (!session) {
return NextResponse.json({
valid: false,
message: "Invalid session"
}, { status: 404 });
}

if (Date.now() > session.expiresAt) {
await deleteSession(sessionId);
return NextResponse.json({
valid: false,
message: "Session expired"
}, { status: 410 });
}
return NextResponse.json({valid: true}, {status: 200});
} catch {
return NextResponse.json({ valid: false, message: "Server error"}, {status: 500});
try {
const sessionId = request.nextUrl.pathname.split('/').pop();
if (!sessionId) {
return NextResponse.json(
{ valid: false, message: 'Invalid session' },
{ status: 404 }
);
}
}
const session = await getSession(sessionId);
if (!session) {
return NextResponse.json(
{
valid: false,
message: 'Invalid session',
},
{ status: 404 }
);
}

if (Date.now() > session.expiresAt) {
await deleteSession(sessionId);
return NextResponse.json(
{
valid: false,
message: 'Session expired',
},
{ status: 410 }
);
}
return NextResponse.json({ valid: true }, { status: 200 });
} catch {
return NextResponse.json(
{ valid: false, message: 'Server error' },
{ status: 500 }
);
}
}
38 changes: 19 additions & 19 deletions peersync/client/src/app/error/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"use client";
'use client';

import { Header } from "../../components/layout/header";
import { Button } from "../../components/ui/button";
import { useSearchParams, useRouter } from "next/navigation";
import { Suspense } from "react";
import { Header } from '../../components/layout/header';
import { Button } from '../../components/ui/button';
import { useSearchParams, useRouter } from 'next/navigation';
import { Suspense } from 'react';

function ErrorContent() {
const searchParams = useSearchParams();
Expand All @@ -14,23 +14,26 @@ function ErrorContent() {
switch (error) {
case 'expired-session':
return {
title: "Session Expired",
description: "This sharing session has expired. Please request a new sharing link."
title: 'Session Expired',
description:
'This sharing session has expired. Please request a new sharing link.',
};
case 'invalid-session':
return {
title: "Invalid Session",
description: "This sharing link is invalid. Please request a new one."
};
title: 'Invalid Session',
description:
'This sharing link is invalid. Please request a new one.',
};
case 'connection-error':
return {
title: "Connection Error",
description: "The connection was lost. This could be due to network issues or because the transfer was cancelled. Please try again."
title: 'Connection Error',
description:
'The connection was lost. This could be due to network issues or because the transfer was cancelled. Please try again.',
};
default:
return {
title: "Error",
description: "Something went wrong. Please try again."
title: 'Error',
description: 'Something went wrong. Please try again.',
};
}
};
Expand All @@ -41,10 +44,7 @@ function ErrorContent() {
<div className="text-center space-y-4">
<h1 className="text-4xl font-bold text-foreground">{title}</h1>
<p className="text-lg text-muted-foreground">{description}</p>
<Button
onClick={() => router.push('/')}
size="sm"
>
<Button onClick={() => router.push('/')} size="sm">
Return Home
</Button>
</div>
Expand All @@ -62,4 +62,4 @@ export default function ErrorPage() {
</main>
</div>
);
}
}
3 changes: 2 additions & 1 deletion peersync/client/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ const inter = Inter({ subsets: ['latin'] });

export const metadata: Metadata = {
title: 'PeerSync | Free Secure File Sharing',
description: 'Share files instantly with end-to-end encryption. No signup required, completely free peer-to-peer file transfer.',
description:
'Share files instantly with end-to-end encryption. No signup required, completely free peer-to-peer file transfer.',
};

export default function RootLayout({
Expand Down
Loading