-
Notifications
You must be signed in to change notification settings - Fork 68
docs: refactor README, offload API docs, and implement unique Cyber N⦠#35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4cbc1de
docs: refactor README, offload API docs, and implement unique Cyber Nβ¦
yash-pouranik dfd6913
fixed refrence error issue in release.controller.js
yash-pouranik a5785e8
Update backend/controllers/release.controller.js
yash-pouranik b43e3d7
Update backend/routes/releases.js
yash-pouranik d3ed1a8
Potential fix for code scanning alert no. 36: Missing rate limiting
yash-pouranik d33a85d
fixed readme
yash-pouranik 5d95bb6
Merge branch 'docs/refactor-readme' of https://github.com/yash-pouranβ¦
yash-pouranik 2943ceb
fix: domain level project api access
yash-pouranik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,145 @@ | ||||||
| # urBackend API Usage Guide π | ||||||
|
|
||||||
| This guide provides technical examples for interacting with the urBackend API. Once your project is created in the dashboard, use your **Public API Key** (for frontend) or **Secret API Key** (for backend) to make requests. | ||||||
|
|
||||||
| ## Base URL | ||||||
|
|
||||||
| ``` | ||||||
| https://api.urbackend.bitbros.in | ||||||
| ``` | ||||||
|
|
||||||
| ## 1. Authentication | ||||||
|
|
||||||
| Manage users for your own applications using urBackend's built-in auth system. | ||||||
|
|
||||||
| ### Sign Up User | ||||||
| ```javascript | ||||||
| await fetch('https://api.urbackend.bitbros.in/api/userAuth/signup', { | ||||||
| method: 'POST', | ||||||
| headers: { | ||||||
| 'Content-Type': 'application/json', | ||||||
| 'x-api-key': 'YOUR_API_KEY' | ||||||
| }, | ||||||
| body: JSON.stringify({ | ||||||
| email: "user@example.com", | ||||||
| password: "securePassword123", | ||||||
| name: "John Doe" // Optional | ||||||
| }) | ||||||
| }); | ||||||
| ``` | ||||||
|
|
||||||
| ### Login User | ||||||
| ```javascript | ||||||
| const res = await fetch('https://api.urbackend.bitbros.in/api/userAuth/login', { | ||||||
| method: 'POST', | ||||||
| headers: { | ||||||
| 'Content-Type': 'application/json', | ||||||
| 'x-api-key': 'YOUR_API_KEY' | ||||||
| }, | ||||||
| body: JSON.stringify({ | ||||||
| email: "user@example.com", | ||||||
| password: "securePassword123" | ||||||
| }) | ||||||
| }); | ||||||
| const data = await res.json(); // Returns { token: "JWT_TOKEN", user: {...} } | ||||||
| ``` | ||||||
|
|
||||||
| ### Get Profile (Me) | ||||||
| ```javascript | ||||||
| await fetch('https://api.urbackend.bitbros.in/api/userAuth/me', { | ||||||
| method: 'GET', | ||||||
| headers: { | ||||||
| 'x-api-key': 'YOUR_API_KEY', | ||||||
| 'Authorization': 'Bearer <USER_TOKEN>' // From login response | ||||||
| } | ||||||
| }); | ||||||
| ``` | ||||||
|
|
||||||
| ## 2. Database API | ||||||
|
|
||||||
| Direct JSON document storage with no database management required. | ||||||
|
|
||||||
| ### Get All Items | ||||||
| ```javascript | ||||||
| // Replace :collectionName with your actual collection name (e.g., 'products') | ||||||
| const res = await fetch('https://api.urbackend.bitbros.in/api/data/products', { | ||||||
| headers: { 'x-api-key': 'YOUR_API_KEY' } | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The example for 'Get All Items' uses
Suggested change
|
||||||
| }); | ||||||
| const data = await res.json(); | ||||||
| ``` | ||||||
|
|
||||||
| ### Insert Data | ||||||
| ```javascript | ||||||
| await fetch('https://api.urbackend.bitbros.in/api/data/products', { | ||||||
| method: 'POST', | ||||||
| headers: { | ||||||
| 'Content-Type': 'application/json', | ||||||
| 'x-api-key': 'YOUR_API_KEY' | ||||||
| }, | ||||||
| body: JSON.stringify({ | ||||||
| name: "MacBook Pro", | ||||||
| price: 1299, | ||||||
| inStock: true | ||||||
| }) | ||||||
| }); | ||||||
| ``` | ||||||
|
|
||||||
| ### Update / Delete by ID | ||||||
| ```javascript | ||||||
| const id = "DOCUMENT_ID"; | ||||||
|
|
||||||
| // Update | ||||||
| await fetch(`https://api.urbackend.bitbros.in/api/data/products/${id}`, { | ||||||
| method: 'PUT', | ||||||
| headers: { | ||||||
| 'Content-Type': 'application/json', | ||||||
| 'x-api-key': 'YOUR_API_KEY' | ||||||
| }, | ||||||
| body: JSON.stringify({ price: 1199 }) | ||||||
| }); | ||||||
|
|
||||||
| // Delete | ||||||
| await fetch(`https://api.urbackend.bitbros.in/api/data/products/${id}`, { | ||||||
| method: 'DELETE', | ||||||
| headers: { 'x-api-key': 'YOUR_API_KEY' } | ||||||
| }); | ||||||
| ``` | ||||||
|
|
||||||
| ## 3. Storage API | ||||||
|
|
||||||
| Manage files and images with ease. | ||||||
|
|
||||||
| ### Upload File | ||||||
| ```javascript | ||||||
| const formData = new FormData(); | ||||||
| formData.append('file', fileInput.files[0]); | ||||||
|
|
||||||
| const res = await fetch('https://api.urbackend.bitbros.in/api/storage/upload', { | ||||||
| method: 'POST', | ||||||
| headers: { 'x-api-key': 'YOUR_API_KEY' }, | ||||||
| body: formData | ||||||
| }); | ||||||
| const data = await res.json(); | ||||||
| // Returns { url: "...", path: "project_id/filename.jpg" } | ||||||
| ``` | ||||||
|
|
||||||
| ### Delete File | ||||||
| ```javascript | ||||||
| await fetch('https://api.urbackend.bitbros.in/api/storage/file', { | ||||||
| method: 'DELETE', | ||||||
| headers: { | ||||||
| 'Content-Type': 'application/json', | ||||||
| 'x-api-key': 'YOUR_API_KEY' | ||||||
| }, | ||||||
| body: JSON.stringify({ | ||||||
| path: "PROJECT_ID/filename.jpg" | ||||||
| }) | ||||||
| }); | ||||||
| ``` | ||||||
|
|
||||||
| ## π Security Best Practices | ||||||
|
|
||||||
| > [!IMPORTANT] | ||||||
| > **Key Separation**: | ||||||
| > - Use the **Publishable Key** (`pk_live_...`) for frontend requests (Read-Only). | ||||||
| > - Use the **Secret Key** (`sk_live_...`) ONLY for backend/secure environments. | ||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For sensitive operations like 'Sign Up User', it's crucial to use the
Secret API Keyas per the 'Security Best Practices'. The currentYOUR_API_KEYplaceholder might lead developers to use a public key in an insecure context. Please update this example to explicitly useYOUR_SECRET_API_KEYor add a comment to clarify its usage.