Skip to content
Merged
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
48 changes: 46 additions & 2 deletions frontend/src/pages/Docs.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState } from 'react';
import { Copy, Terminal, Database, Shield, HardDrive, Check, Server, Menu, X, ChevronDown, AlertCircle, Zap } from 'lucide-react';
import { Copy, Terminal, Database, Shield, HardDrive, Check, Server, Menu, X, ChevronDown, AlertCircle, Zap, AlertTriangle } from 'lucide-react';
import { API_URL } from '../config';

import Footer from '../components/Layout/Footer';
Expand Down Expand Up @@ -88,6 +88,28 @@ console.log(data);
</div>
);

// Helper for Error Status Codes Table
const ErrorTable = ({ errors }) => (
<div style={{ margin: '1rem 0', overflowX: 'auto' }}>
<table style={{ width: '100%', fontSize: '0.9rem', borderCollapse: 'collapse' }}>
<thead>
<tr style={{ borderBottom: '1px solid #333', textAlign: 'left' }}>
<th style={{ padding: '8px', color: '#888' }}>Status Code</th>
<th style={{ padding: '8px', color: '#888' }}>Description</th>
</tr>
</thead>
<tbody>
{errors.map((e, i) => (
<tr key={i} style={{ borderBottom: '1px solid #222' }}>
<td style={{ padding: '8px', fontFamily: 'monospace', color: 'var(--color-primary)' }}>{e.code}</td>
<td style={{ padding: '8px', color: '#ddd' }}>{e.desc}</td>
</tr>
))}
</tbody>
</table>
</div>
);

const renderContent = () => {
switch (activeTab) {
case 'intro':
Expand Down Expand Up @@ -131,6 +153,27 @@ console.log(data);
</div>
);

case 'errors':
return (
<div className="fade-in">
<h2 className="page-title" style={{ marginBottom: '1rem' }}>Error Reference</h2>
<p style={{ color: 'var(--color-text-muted)', marginBottom: '2rem' }}>
Common HTTP status codes and their meanings when making API requests.
</p>

<h3 style={{ fontSize: '1.2rem', marginBottom: '1rem', display: 'flex', alignItems: 'center', gap: '10px' }}>
<AlertTriangle size={18} /> Status Codes
</h3>
<ErrorTable errors={[
{ code: '400 Bad Request', desc: 'Invalid JSON or missing required schema fields.' },
{ code: '401 Unauthorized', desc: 'Invalid or missing API Key/JWT Token.' },
{ code: '403 Forbidden', desc: 'Resource limits exceeded (e.g., database or storage quota).' },
{ code: '404 Not Found', desc: 'Collection or document does not exist.' },
{ code: '500 Internal Server Error', desc: 'Unexpected server-side issues.' },
]} />
</div>
);
Comment on lines +156 to +175

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for HTTP status code patterns in the codebase
rg -n --hidden --no-ignore-vcs -S "status\(4(00|01|03|04)\)|status\(429\)|status\(500\)|HTTP\s*4(00|01|03|04)|HTTP\s*429|HTTP\s*500|Too Many Requests|429" .

Repository: yash-pouranik/urBackend

Length of output: 14719


🏁 Script executed:

#!/bin/bash
# Explore the backend directory structure
find . -type f -name "*.js" -o -name "*.ts" -o -name "*.py" -o -name "*.go" -o -name "*.java" | head -30

Repository: yash-pouranik/urBackend

Length of output: 1018


🏁 Script executed:

#!/bin/bash
# Look for backend API/error handler files
fd -e js -e ts -e py "api|server|error|handler|route" . | grep -v node_modules | head -20

Repository: yash-pouranik/urBackend

Length of output: 160


🏁 Script executed:

cat -n backend/middleware/api_usage.js

Repository: yash-pouranik/urBackend

Length of output: 1716


🏁 Script executed:

# Also check for any rate limiting logic in the project controller
rg -n "api_usage|rate|limit|429|Too Many" backend/ -i

Repository: yash-pouranik/urBackend

Length of output: 7374


Add 429 status code for rate limiting to the documented error reference.

The frontend documentation correctly documents 403 for resource limit errors (database/storage quota exceeded), which matches the backend implementation. However, the docs are incomplete: the backend uses express-rate-limit middleware (in backend/middleware/api_usage.js) which returns 429 Too Many Requests when the 100 requests per 15 minutes limit is exceeded on /api/data, /api/storage, and /api/userAuth endpoints. The docs should also mention 413 Payload Too Large for when file uploads exceed size limits.

🤖 Prompt for AI Agents
In @frontend/src/pages/Docs.jsx around lines 156 - 175, Update the Error
Reference array in the case 'errors' render of Docs.jsx (the ErrorTable call) to
include entries for '429 Too Many Requests' with a description like "Rate limit
exceeded (100 requests per 15 minutes) for /api/data, /api/storage,
/api/userAuth" and '413 Payload Too Large' with a description like "Uploaded
file exceeds maximum allowed size"; keep the existing entries unchanged and
ensure the new objects follow the same { code, desc } shape passed to
ErrorTable.


case 'limits':
return (
<div className="fade-in">
Expand Down Expand Up @@ -359,7 +402,8 @@ console.log("File URL:", result.url);
<ul style={{ listStyle: 'none', padding: 0 }}>
{[
{ id: 'intro', label: 'Introduction', icon: Terminal },
{ id: 'limits', label: 'Limits & Quotas', icon: AlertCircle }, // New Tab
{ id: 'errors', label: 'Error Reference', icon: AlertTriangle },
{ id: 'limits', label: 'Limits & Quotas', icon: AlertCircle },
{ id: 'auth', label: 'Authentication', icon: Shield },
{ id: 'data', label: 'Database & API', icon: Database },
{ id: 'storage', label: 'Storage', icon: HardDrive },
Expand Down
Loading