Skip to content

Commit 132ef55

Browse files
updated projects
1 parent d1732ba commit 132ef55

File tree

21 files changed

+4254
-66
lines changed

21 files changed

+4254
-66
lines changed

app/api/chat/route.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ export async function POST(req: Request) {
8282

8383
console.log(`[Chat API ${requestId}] Validation passed for model: ${model.id} (${model.providerId})`)
8484

85-
// Analyze uploaded files if present
8685
let projectStructure: ProjectStructure | undefined
8786
if (uploadedFiles && uploadedFiles.length > 0) {
8887
try {

app/api/project-templates/route.ts

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
import { NextResponse } from 'next/server';
2+
3+
const SAMPLE_TEMPLATES = [
4+
{
5+
id: "nextjs-app",
6+
name: "nextjs-app",
7+
display_name: "Next.js Application",
8+
description: "Modern React application with Next.js 14, TypeScript, Tailwind CSS, and shadcn/ui components. Perfect for building fast, SEO-friendly web applications.",
9+
category: "web",
10+
language: "typescript",
11+
framework: "nextjs",
12+
tags: ["typescript", "tailwind", "app-router", "ssr", "seo"],
13+
config: {
14+
template: "nextjs-developer",
15+
features: ["typescript", "tailwind", "app-router", "shadcn-ui"]
16+
},
17+
is_official: true,
18+
is_featured: true,
19+
usage_count: 1250,
20+
demo_url: "https://nextjs-template-demo.vercel.app"
21+
},
22+
{
23+
id: "react-component",
24+
name: "react-component",
25+
display_name: "React Component Library",
26+
description: "Reusable React component library with TypeScript, Storybook for documentation, and comprehensive testing setup.",
27+
category: "library",
28+
language: "typescript",
29+
framework: "react",
30+
tags: ["components", "storybook", "testing", "npm-package"],
31+
config: {
32+
template: "nextjs-developer",
33+
features: ["components", "storybook", "testing", "rollup"]
34+
},
35+
is_official: true,
36+
is_featured: false,
37+
usage_count: 450
38+
},
39+
{
40+
id: "vue-app",
41+
name: "vue-app",
42+
display_name: "Vue.js Application",
43+
description: "Modern Vue 3 application with Composition API, Vite build tool, TypeScript support, and Vuetify components.",
44+
category: "web",
45+
language: "typescript",
46+
framework: "vue",
47+
tags: ["vue3", "composition-api", "vite", "vuetify"],
48+
config: {
49+
template: "vue-developer",
50+
features: ["vue3", "composition-api", "vite", "typescript"]
51+
},
52+
is_official: true,
53+
is_featured: true,
54+
usage_count: 780
55+
},
56+
{
57+
id: "python-api",
58+
name: "python-api",
59+
display_name: "FastAPI Backend",
60+
description: "High-performance Python API with FastAPI, async support, automatic OpenAPI documentation, and PostgreSQL integration.",
61+
category: "api",
62+
language: "python",
63+
framework: "fastapi",
64+
tags: ["fastapi", "async", "openapi", "postgresql", "uvicorn"],
65+
config: {
66+
template: "code-interpreter-v1",
67+
features: ["fastapi", "async", "openapi", "database"]
68+
},
69+
is_official: true,
70+
is_featured: true,
71+
usage_count: 920
72+
},
73+
{
74+
id: "streamlit-dashboard",
75+
name: "streamlit-app",
76+
display_name: "Streamlit Dashboard",
77+
description: "Interactive data dashboard with Streamlit, Plotly charts, pandas data processing, and machine learning integration.",
78+
category: "data",
79+
language: "python",
80+
framework: "streamlit",
81+
tags: ["dashboard", "charts", "data-analysis", "ml", "plotly"],
82+
config: {
83+
template: "streamlit-developer",
84+
features: ["dashboard", "charts", "ml", "data-processing"]
85+
},
86+
is_official: true,
87+
is_featured: true,
88+
usage_count: 650
89+
},
90+
{
91+
id: "landing-page",
92+
name: "landing-page",
93+
display_name: "Landing Page",
94+
description: "High-converting landing page with modern design, SEO optimization, analytics integration, and conversion tracking.",
95+
category: "marketing",
96+
language: "typescript",
97+
framework: "nextjs",
98+
tags: ["landing", "seo", "conversion", "analytics", "marketing"],
99+
config: {
100+
template: "nextjs-developer",
101+
features: ["landing", "seo", "conversion", "analytics"]
102+
},
103+
is_official: true,
104+
is_featured: false,
105+
usage_count: 380
106+
},
107+
{
108+
id: "mobile-app",
109+
name: "react-native-app",
110+
display_name: "React Native App",
111+
description: "Cross-platform mobile application with React Native, Expo, TypeScript, and native device integrations.",
112+
category: "mobile",
113+
language: "typescript",
114+
framework: "react-native",
115+
tags: ["mobile", "expo", "cross-platform", "ios", "android"],
116+
config: {
117+
template: "nextjs-developer", // Adapted for React Native
118+
features: ["expo", "navigation", "async-storage", "push-notifications"]
119+
},
120+
is_official: true,
121+
is_featured: false,
122+
usage_count: 290
123+
},
124+
{
125+
id: "fullstack-app",
126+
name: "fullstack-app",
127+
display_name: "Full-Stack Application",
128+
description: "Complete full-stack application with Next.js frontend, FastAPI backend, PostgreSQL database, and deployment ready.",
129+
category: "web",
130+
language: "typescript",
131+
framework: "nextjs",
132+
tags: ["fullstack", "nextjs", "fastapi", "postgresql", "deployment"],
133+
config: {
134+
template: "nextjs-developer",
135+
features: ["frontend", "backend", "database", "auth", "deployment"]
136+
},
137+
is_official: true,
138+
is_featured: true,
139+
usage_count: 560
140+
}
141+
];
142+
143+
export async function GET() {
144+
try {
145+
return NextResponse.json({ templates: SAMPLE_TEMPLATES });
146+
} catch (error) {
147+
console.error("Error fetching project templates:", error);
148+
return NextResponse.json({ error: "Failed to fetch project templates" }, { status: 500 });
149+
}
150+
}

app/api/projects/route.ts

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ if (!supabaseServiceRoleKey) {
1313
throw new Error("CRITICAL: SUPABASE_SERVICE_ROLE_KEY environment variable is not defined.");
1414
}
1515
const supabase = createClient(supabaseUrl, supabaseServiceRoleKey)
16+
console.log('[api/projects/route.ts] Supabase client initialized (using service role key):', supabase ? 'OK' : 'Failed');
1617

1718
const createProjectSchema = z.object({
1819
name: z.string().min(1).max(50),
@@ -24,54 +25,65 @@ const createProjectSchema = z.object({
2425

2526
async function getUserFromAuth(request: NextRequest) {
2627
const authHeader = request.headers.get('authorization')
28+
console.log('[api/projects/route.ts] getUserFromAuth - authHeader:', authHeader ? 'Present' : 'Missing');
2729
if (!authHeader || !authHeader.startsWith('Bearer ')) {
30+
console.warn('[api/projects/route.ts] getUserFromAuth - No Bearer token found.');
2831
return null
2932
}
3033

3134
const token = authHeader.substring(7)
35+
// console.log('[api/projects/route.ts] getUserFromAuth - Extracted token:', token); // Be careful logging tokens
3236
const { data: { user }, error } = await supabase.auth.getUser(token)
37+
console.log('[api/projects/route.ts] getUserFromAuth - supabase.auth.getUser result - user ID:', user?.id, 'error:', error);
3338

3439
if (error || !user) {
40+
console.warn('[api/projects/route.ts] getUserFromAuth - Failed to get user from token or no user.', { error: error?.message });
3541
return null
3642
}
3743

44+
console.log('[api/projects/route.ts] getUserFromAuth - User successfully retrieved:', user.id);
3845
return user
3946
}
4047

41-
// GET /api/projects - Get user's projects
4248
export async function GET(request: NextRequest) {
49+
console.log('[api/projects/route.ts] GET request received.');
4350
try {
4451
const user = await getUserFromAuth(request)
4552
if (!user) {
53+
console.warn('[api/projects/route.ts] GET - Unauthorized access attempt.');
4654
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
4755
}
4856

57+
console.log(`[api/projects/route.ts] GET - Authenticated user: ${user.id}. Fetching projects.`);
4958
const { data: projects, error } = await supabase
5059
.from('projects')
5160
.select('*')
5261
.eq('user_id', user.id)
5362
.order('updated_at', { ascending: false })
5463

5564
if (error) {
56-
console.error('Error fetching projects:', error)
65+
console.error('[api/projects/route.ts] GET - Error fetching projects from Supabase:', error);
5766
return NextResponse.json({ error: 'Failed to fetch projects' }, { status: 500 })
5867
}
5968

69+
console.log(`[api/projects/route.ts] GET - Successfully fetched ${projects?.length || 0} projects for user ${user.id}.`);
6070
return NextResponse.json({ projects })
6171
} catch (error) {
62-
console.error('GET /api/projects error:', error)
72+
console.error('[api/projects/route.ts] GET - Unexpected error:', error);
6373
return NextResponse.json({ error: 'Internal server error' }, { status: 500 })
6474
}
6575
}
6676

67-
// POST /api/projects - Create new project
6877
export async function POST(request: NextRequest) {
78+
console.log('[api/projects/route.ts] POST request received.');
6979
try {
7080
const user = await getUserFromAuth(request)
7181
if (!user) {
82+
console.warn('[api/projects/route.ts] POST - Unauthorized access attempt.');
7283
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
7384
}
7485

86+
console.log(`[api/projects/route.ts] POST - Authenticated user: ${user.id}. Processing new project.`);
7587
const body = await request.json()
7688
const validatedData = createProjectSchema.parse(body)
7789

@@ -88,17 +100,19 @@ export async function POST(request: NextRequest) {
88100
.single()
89101

90102
if (error) {
91-
console.error('Error creating project:', error)
103+
console.error('[api/projects/route.ts] POST - Error creating project in Supabase:', error);
92104
return NextResponse.json({ error: 'Failed to create project' }, { status: 500 })
93105
}
94106

107+
console.log(`[api/projects/route.ts] POST - Successfully created project ${project.id} for user ${user.id}.`);
95108
return NextResponse.json({ project }, { status: 201 })
96109
} catch (error) {
97110
if (error instanceof z.ZodError) {
111+
console.warn('[api/projects/route.ts] POST - Invalid input:', error.errors);
98112
return NextResponse.json({ error: 'Invalid input', details: error.errors }, { status: 400 })
99113
}
100114

101-
console.error('POST /api/projects error:', error)
115+
console.error('[api/projects/route.ts] POST - Unexpected error:', error);
102116
return NextResponse.json({ error: 'Internal server error' }, { status: 500 })
103117
}
104-
}
118+
}

app/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,4 @@ export default function RootLayout({
6767
</PostHogProvider>
6868
</html>
6969
)
70-
}
70+
}

0 commit comments

Comments
 (0)