-
Notifications
You must be signed in to change notification settings - Fork 68
feat(cli): implement official urBackend CLI (@urbackend/cli)
#340
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
yash-pouranik
merged 14 commits into
geturbackend:main
from
Nitin-kumar-yadav1307:feat/official-cli
Jun 28, 2026
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
4ce8947
feat(cli): scaffold official CLI package
Nitin-kumar-yadav1307 d160df3
feat(cli): initialize CLI with Commander
Nitin-kumar-yadav1307 262006b
feat(cli): scaffold official urBackend CLI authentication
Nitin-kumar-yadav1307 da88ad4
feat(cli): implement authentication commands
Nitin-kumar-yadav1307 075393a
pre-ui PAT commit
Nitin-kumar-yadav1307 576c4cb
final commit- official urBackend CLI
Nitin-kumar-yadav1307 ad8a7d0
ci: add REDIS_URL env for dashboard-api test job
Nitin-kumar-yadav1307 bd145a9
test: mock authenticateCLI and authFlexible in routes.user.test
Nitin-kumar-yadav1307 cf0598c
test: mock cli.controller to prevent ESM marked import in Jest
Nitin-kumar-yadav1307 ca1c70b
proposed fix by coderabbit
Nitin-kumar-yadav1307 9f20781
fixed ci.yml
Nitin-kumar-yadav1307 f36ecc6
coderabbit agentic fix
Nitin-kumar-yadav1307 f9ab23f
revert: restore NODE_ENV guard in authMiddleware console.error
Nitin-kumar-yadav1307 13b672c
removed extra landing space in ci.yml
Nitin-kumar-yadav1307 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
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
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
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,28 @@ | ||
| const { Developer, ApiResponse, AppError } = require("@urbackend/common"); | ||
|
|
||
| module.exports.getCLIProfile = async (req, res, next) => { | ||
| try { | ||
| const developer = await Developer.findById(req.user._id) | ||
| .select("email plan githubUsername avatarUrl"); | ||
|
|
||
| if (!developer) { | ||
| return next(new AppError(404, "Developer not found")); | ||
| } | ||
|
|
||
| return new ApiResponse({ | ||
| developer: { | ||
| id: developer._id, | ||
| email: developer.email, | ||
| plan: developer.plan, | ||
| githubUsername: developer.githubUsername, | ||
| avatarUrl: developer.avatarUrl, | ||
| }, | ||
| auth: { | ||
| scopes: req.cliScopes, | ||
| tokenType: req.cliTokenType, | ||
| }, | ||
| }).send(res); | ||
| } catch (err) { | ||
| next(err); | ||
| } | ||
| }; |
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
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,19 @@ | ||
| const authMiddleware = require('./authMiddleware'); | ||
| const authenticateCLI = require('./authenticateCLI'); | ||
|
|
||
| /** | ||
| * Flexible auth middleware — accepts either: | ||
| * - Session cookie (browser dashboard) | ||
| * - Bearer PAT token (CLI) | ||
| */ | ||
| const authFlexible = (req, res, next) => { | ||
| const authHeader = req.headers.authorization; | ||
|
|
||
| if (authHeader && authHeader.startsWith('Bearer ubpat_')) { | ||
| return authenticateCLI(req, res, next); | ||
| } | ||
|
|
||
| return authMiddleware(req, res, next); | ||
| }; | ||
|
|
||
| module.exports = authFlexible; | ||
|
yash-pouranik marked this conversation as resolved.
|
||
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
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
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
Empty file.
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.