-
Notifications
You must be signed in to change notification settings - Fork 5
napi login
command
#147
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
base: main
Are you sure you want to change the base?
napi login
command
#147
Conversation
import { input } from "npm:@inquirer/prompts"; | ||
|
||
function isValidEmail(email: string): boolean { | ||
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email); |
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.
We can use zod for this, we already use it in the CLI for other stuff
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.
Fixed
}, | ||
}); | ||
|
||
const response = await fetch("https://api.nanoapi.io/v1/auth/requestOtp", { |
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.
Need some global option to override this in the CLI, usefull for working locally, will also be used for poeple having self hosted version in the future
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.
Added
return; | ||
} | ||
|
||
const resposne = await fetch(url, { |
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.
typo
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.
Fixed
} | ||
} | ||
|
||
export function setUserAuthToken(token: string) { |
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.
Here we could also setup the user email from the token we get.
Usefull for when we send telemetry
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.
Added
packages/cli/src/cli/index.ts
Outdated
host: { | ||
type: "string" as PositionalOptionsType, | ||
default: "https://api.nanoapi.io", | ||
alias: "h", |
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.
This alias already taken by the defaul "help" command
Maybe we can do "api_host" and helper "ah"?
Or no alias at all
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 info, the help command is not codded, handled by yargs
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.
Ah alright good to know
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.
I've set it to uppercase -H
. This should be fine for now and if we need to change it in a future release we can rename it to something else then.
Type of change
not work as expected)
Description
Please include a summary of the changes and the related issue. Explain the
motivation behind this change.
Related Issue
Issue Number: #<issue_number>
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Checklist