Skip to content

Commit 659f5eb

Browse files
Merge pull request #33 from Gerome-Elassaad/feature/update-sections
Feature/update sections
2 parents dcba71d + 06e29c2 commit 659f5eb

File tree

34 files changed

+977
-714
lines changed

34 files changed

+977
-714
lines changed

AGENTS.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Agent Guidelines for CodingIT
2+
3+
## Build/Lint/Test Commands
4+
- **Development**: `npm run dev` (Next.js with Turbo)
5+
- **Build**: `npm run build` (Next.js production build)
6+
- **Start**: `npm run start` (Next.js production server)
7+
- **Lint**: `npm run lint` (ESLint with Next.js rules)
8+
- **No test framework configured** - run lint after changes
9+
10+
## Code Style Guidelines
11+
12+
### Formatting
13+
- **Quotes**: Single quotes only (`'string'`)
14+
- **Semicolons**: Never use semicolons
15+
- **Imports**: Auto-sorted with `@trivago/prettier-plugin-sort-imports`
16+
17+
### TypeScript
18+
- **Strict mode**: Enabled in `tsconfig.json`
19+
- **Path aliases**: Use `@/*` for relative imports from root
20+
- **Types**: Always use explicit types, prefer interfaces for objects
21+
22+
### Naming Conventions
23+
- **Variables/Functions**: camelCase (`userName`, `getUserData`)
24+
- **Components**: PascalCase (`UserProfile`, `ChatInput`)
25+
- **Files**: kebab-case for components (`user-profile.tsx`), camelCase for utilities (`authUtils.ts`)
26+
27+
### Error Handling
28+
- Use `console.warn()` for non-critical warnings
29+
- Handle async errors with `.catch()` or try-catch
30+
- Validate inputs with TypeScript types and runtime checks
31+
32+
### Imports
33+
- Group imports: React/Next, third-party libraries, local utilities
34+
- Use absolute imports with `@/` alias
35+
- Sort imports automatically (handled by Prettier plugin)
36+
37+
### Best Practices
38+
- No comments unless absolutely necessary
39+
- Use functional components with hooks
40+
- Follow React/Next.js conventions
41+
- Maintain consistent file structure

app/api/billing/update/route.ts

Lines changed: 0 additions & 123 deletions
This file was deleted.

app/api/files/content/route.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { NextResponse } from 'next/server'
22
import { Sandbox } from '@e2b/code-interpreter'
3+
import { LRUCache } from 'lru-cache'
4+
5+
const cache = new LRUCache<string, string>({
6+
max: 500,
7+
ttl: 1000 * 60 * 5, // 5 minutes
8+
})
39

410
export const runtime = 'nodejs'
511
export const dynamic = 'force-dynamic'
@@ -41,8 +47,18 @@ export async function GET(req: Request) {
4147
)
4248
}
4349

50+
const cacheKey = `${sessionID}:${path}`
51+
const cachedContent = cache.get(cacheKey)
52+
53+
if (cachedContent) {
54+
return NextResponse.json({ content: cachedContent })
55+
}
56+
4457
const sandbox = await getSandbox(sessionID, template || undefined)
4558
const content = await sandbox.files.read(path)
59+
60+
cache.set(cacheKey, content)
61+
4662
return NextResponse.json({ content })
4763
} catch (error: any) {
4864
return NextResponse.json(
@@ -65,6 +81,10 @@ export async function POST(req: Request) {
6581

6682
const sandbox = await getSandbox(sessionID, template || undefined)
6783
await sandbox.files.write(path, content)
84+
85+
const cacheKey = `${sessionID}:${path}`
86+
cache.delete(cacheKey)
87+
6888
return NextResponse.json({ success: true })
6989
} catch (error: any) {
7090
return NextResponse.json(

app/api/files/route.ts

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { NextRequest, NextResponse } from 'next/server'
22
import { Sandbox, FileType } from '@e2b/code-interpreter'
33
import { FileSystemNode } from '@/components/file-tree'
4+
import { getSandbox } from '@/lib/sandbox'
45

56
export const runtime = 'nodejs'
67
export const dynamic = 'force-dynamic'
@@ -31,26 +32,6 @@ async function listFilesRecursively(
3132
return nodes
3233
}
3334

34-
const E2B_API_KEY = process.env.E2B_API_KEY
35-
36-
const sandboxTimeout = 10 * 60 * 1000
37-
38-
async function getSandbox(sessionID: string, template?: string) {
39-
if (!E2B_API_KEY) {
40-
throw new Error('E2B_API_KEY environment variable not found')
41-
}
42-
43-
const sandbox = await Sandbox.create(template || 'code-interpreter-v1', {
44-
apiKey: E2B_API_KEY,
45-
metadata: {
46-
sessionID,
47-
template: template || 'code-interpreter-v1',
48-
},
49-
timeoutMs: sandboxTimeout,
50-
})
51-
return sandbox
52-
}
53-
5435
export async function GET(request: NextRequest) {
5536
const searchParams = request.nextUrl.searchParams
5637
const sessionID = searchParams.get('sessionID')

app/api/stripe/checkout/route.ts

Lines changed: 0 additions & 64 deletions
This file was deleted.

app/api/stripe/portal/route.ts

Lines changed: 0 additions & 54 deletions
This file was deleted.

0 commit comments

Comments
 (0)