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
24 changes: 12 additions & 12 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -597,11 +597,11 @@ jobs:
ci: {
collect: {
url: [
'${{ steps.deploy-production.outputs.deployment-url }}/',
'${{ steps.deploy-production.outputs.deployment-url }}/about',
'${{ steps.deploy-production.outputs.deployment-url }}/hackathons',
'${{ steps.deploy-production.outputs.deployment-url }}/leaderboard',
'${{ steps.deploy-production.outputs.deployment-url }}/auth/signin'
'${{ needs.deploy-production.outputs.deployment-url }}/',
'${{ needs.deploy-production.outputs.deployment-url }}/about',
'${{ needs.deploy-production.outputs.deployment-url }}/hackathons',
'${{ needs.deploy-production.outputs.deployment-url }}/leaderboard',
'${{ needs.deploy-production.outputs.deployment-url }}/auth/signin'
],
numberOfRuns: 3,
settings: {
Expand Down Expand Up @@ -653,7 +653,7 @@ jobs:
- name: Run Lighthouse CI on deployed site
run: |
echo "🚀 Starting Lighthouse CI performance testing..."
echo "Testing URL: ${{ steps.deploy-production.outputs.deployment-url }}"
echo "Testing URL: ${{ needs.deploy-production.outputs.deployment-url }}"

# Run Lighthouse CI with the deployed configuration
lhci autorun --config=lighthouserc-deployed.js
Expand Down Expand Up @@ -715,11 +715,11 @@ jobs:
ci: {
collect: {
url: [
'${{ steps.deploy-staging.outputs.deployment-url }}/',
'${{ steps.deploy-staging.outputs.deployment-url }}/about',
'${{ steps.deploy-staging.outputs.deployment-url }}/hackathons',
'${{ steps.deploy-staging.outputs.deployment-url }}/leaderboard',
'${{ steps.deploy-staging.outputs.deployment-url }}/auth/signin'
'${{ needs.deploy-staging.outputs.deployment-url }}/',
'${{ needs.deploy-staging.outputs.deployment-url }}/about',
'${{ needs.deploy-staging.outputs.deployment-url }}/hackathons',
'${{ needs.deploy-staging.outputs.deployment-url }}/leaderboard',
'${{ needs.deploy-staging.outputs.deployment-url }}/auth/signin'
],
numberOfRuns: 2,
settings: {
Expand Down Expand Up @@ -765,7 +765,7 @@ jobs:
- name: Run Lighthouse CI on staging site
run: |
echo "🚀 Starting Lighthouse CI performance testing on staging..."
echo "Testing URL: ${{ steps.deploy-staging.outputs.deployment-url }}"
echo "Testing URL: ${{ needs.deploy-staging.outputs.deployment-url }}"

# Run Lighthouse CI with the staging configuration
lhci autorun --config=lighthouserc-staging.js
Expand Down
105 changes: 105 additions & 0 deletions app/admin/settings/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
import { Button } from '@/components/ui/button';
import { Settings, Shield, Database, Users, Bell } from 'lucide-react';

export default function AdminSettingsPage() {
return (
<div className="container mx-auto py-6">
<div className="mb-6">
<h1 className="text-3xl font-bold text-gray-900 dark:text-white">
System Settings
</h1>
<p className="text-gray-600 dark:text-gray-400 mt-2">
Configure system-wide settings and preferences
</p>
</div>

<div className="grid gap-6 md:grid-cols-2 lg:grid-cols-3">
<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2">
<Shield className="h-5 w-5" />
Security Settings
</CardTitle>
<CardDescription>
Configure security policies and access controls
</CardDescription>
</CardHeader>
<CardContent>
<Button variant="outline" className="w-full">
Manage Security
</Button>
</CardContent>
</Card>

<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2">
<Database className="h-5 w-5" />
Database Settings
</CardTitle>
<CardDescription>
Manage database connections and backups
</CardDescription>
</CardHeader>
<CardContent>
<Button variant="outline" className="w-full">
Database Config
</Button>
</CardContent>
</Card>

<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2">
<Users className="h-5 w-5" />
User Management
</CardTitle>
<CardDescription>
Configure user roles and permissions
</CardDescription>
</CardHeader>
<CardContent>
<Button variant="outline" className="w-full">
User Settings
</Button>
</CardContent>
</Card>

<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2">
<Bell className="h-5 w-5" />
Notifications
</CardTitle>
<CardDescription>
Configure notification preferences
</CardDescription>
</CardHeader>
<CardContent>
<Button variant="outline" className="w-full">
Notification Settings
</Button>
</CardContent>
</Card>

<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2">
<Settings className="h-5 w-5" />
General Settings
</CardTitle>
<CardDescription>
Basic system configuration
</CardDescription>
</CardHeader>
<CardContent>
<Button variant="outline" className="w-full">
General Config
</Button>
</CardContent>
</Card>
</div>
</div>
);
}
18 changes: 18 additions & 0 deletions app/admin/test/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { TestManager } from '@/components/admin/TestManager';

export default function AdminTestPage() {
return (
<div className="container mx-auto py-6">
<div className="mb-6">
<h1 className="text-3xl font-bold text-gray-900 dark:text-white">
Test Management
</h1>
<p className="text-gray-600 dark:text-gray-400 mt-2">
Manage coding tests, questions, and results
</p>
</div>

<TestManager />
</div>
);
}
11 changes: 4 additions & 7 deletions app/api/leaderboard/stats/route-unified.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import { createClient } from '@supabase/supabase-js';
import { UnifiedCache } from '@/lib/unified-cache-system';

// Create Supabase client function to avoid build-time initialization
function getSupabaseClient() {
const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL!;
const supabaseServiceKey = process.env.SUPABASE_SERVICE_ROLE_KEY!;
return createClient(supabaseUrl, supabaseServiceKey);
}
const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL!;
const supabaseServiceKey = process.env.SUPABASE_SERVICE_ROLE_KEY!;

const supabaseAdmin = createClient(supabaseUrl, supabaseServiceKey);

export async function GET() {
try {
const supabaseAdmin = getSupabaseClient();
const stats = await UnifiedCache.cachedQuery(
'leaderboard-stats',
async () => {
Expand Down
11 changes: 4 additions & 7 deletions app/api/leaderboard/user/[userId]/route-unified.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@ import { NextRequest } from 'next/server';
import { createClient } from '@supabase/supabase-js';
import { UnifiedCache } from '@/lib/unified-cache-system';

// Create Supabase client function to avoid build-time initialization
function getSupabaseClient() {
const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL!;
const supabaseServiceKey = process.env.SUPABASE_SERVICE_ROLE_KEY!;
return createClient(supabaseUrl, supabaseServiceKey);
}
const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL!;
const supabaseServiceKey = process.env.SUPABASE_SERVICE_ROLE_KEY!;

const supabaseAdmin = createClient(supabaseUrl, supabaseServiceKey);

export async function GET(
request: NextRequest,
{ params }: { params: { userId: string } }
) {
try {
const supabaseAdmin = getSupabaseClient();
const userId = params.userId;

if (!userId) {
Expand Down
8 changes: 4 additions & 4 deletions lib/security/csp-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ export function generateNonce(): string {
export function getCSPConfig(request: NextRequest): CSPConfig {
const nonce = generateNonce();

// Enhanced CSP policy without unsafe directives
// Enhanced CSP policy with Cloudflare Insights support
const policy = [
"default-src 'self'",
"script-src 'self' 'nonce-" + nonce + "' https://vercel.live https://va.vercel-scripts.com",
"style-src 'self' 'nonce-" + nonce + "' https://fonts.googleapis.com",
"script-src 'self' 'nonce-" + nonce + "' 'unsafe-inline' 'unsafe-eval' https://vercel.live https://va.vercel-scripts.com https://static.cloudflareinsights.com",
"style-src 'self' 'nonce-" + nonce + "' 'unsafe-inline' https://fonts.googleapis.com",
"font-src 'self' https://fonts.gstatic.com",
"img-src 'self' data: https: blob:",
"connect-src 'self' https://*.supabase.co https://*.vercel.app wss://*.supabase.co",
Expand Down Expand Up @@ -77,7 +77,7 @@ export function applyCSPHeaders(response: Response, cspConfig: CSPConfig): Respo
export function getDevelopmentCSP(): string {
return [
"default-src 'self'",
"script-src 'self' 'unsafe-eval' 'unsafe-inline'",
"script-src 'self' 'unsafe-eval' 'unsafe-inline' https://vercel.live https://va.vercel-scripts.com https://static.cloudflareinsights.com",
"style-src 'self' 'unsafe-inline' https://fonts.googleapis.com",
"font-src 'self' https://fonts.gstatic.com",
"img-src 'self' data: https: blob:",
Expand Down
Loading