-
Notifications
You must be signed in to change notification settings - Fork 7.1k
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
fix: fix keepAlive parameter error #4194
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* @param { Readonly<Promise> } promise | ||
* @param {object=} errorExt - Additional Information you can pass to the err object | ||
* @return { Promise } | ||
*/ | ||
export async function to<T, U = Error>( | ||
promise: Readonly<Promise<T>>, | ||
errorExt?: object, | ||
): Promise<[null, T] | [U, undefined]> { | ||
try { | ||
const data = await promise; | ||
const result: [null, T] = [null, data]; | ||
return result; | ||
} catch (error) { | ||
if (errorExt) { | ||
const parsedError = Object.assign({}, error, errorExt); | ||
return [parsedError as U, undefined]; | ||
} | ||
return [error as U, undefined]; | ||
} | ||
} | ||
Comment on lines
+1
to
+21
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. New utility function This utility function provides a clean way to handle promises with error extensions. Consider adding unit tests to ensure its reliability. Would you like me to generate unit tests for this utility function or open a GitHub issue to track this task? |
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.
Security Concern: Avoid hardcoding secrets.
Hardcoding secrets like
ACCESS_TOKEN_SECRET
andREFRESH_TOKEN_SECRET
poses a security risk. Consider using environment variables or a secure vault for managing secrets.Committable suggestion