-
Notifications
You must be signed in to change notification settings - Fork 168
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
Feat: NextJS user api #246
Conversation
Risk Level 2 - /home/runner/work/code-review-gpt/code-review-gpt/services/web-app/src/app/profile/page.tsx
Suggested Changes:
export default function Profile(): JSX.Element {
// code
}
useEffect(() => {
const fetchData = async () => {
// code
};
if (!user) {
await fetchData();
}
}, [session?.user?.userId, user]);
useEffect(() => {
// code
return () => {
// cleanup code
};
}, [session?.user?.userId, user]);
useEffect(() => {
// code
return () => {
// cleanup code
};
}, [session?.user?.userId, user]);
// return statement Risk Level 2 - /home/runner/work/code-review-gpt/code-review-gpt/services/web-app/src/pages/api/user/getUser.ts
Suggested Changes:
export const getUser = async (
getUserProps: GetUserProps,
axiosInstance: AxiosInstance
): Promise<UserBody> => {
// code
};
export const getUser = async (
getUserProps: GetUserProps,
axiosInstance: AxiosInstance
): Promise<UserBody> => {
try {
// code
} catch (error) {
console.error(\"Failed to getUser:\", error);
throw error;
}
};
export const getUser = async (
getUserProps: GetUserProps,
axiosInstance: AxiosInstance
): Promise<UserBody> => {
const [loading, setLoading] = useState(false);
try {
setLoading(true);
// code
} catch (error) {
console.error(\"Failed to getUser:\", error);
throw error;
} finally {
setLoading(false);
}
};
export const getUser = async (
getUserProps: GetUserProps,
axiosInstance: AxiosInstance
): Promise<UserBody> => {
const response = await axiosInstance.get<string>(`/getUser?userId=${getUserProps.userId}`);
const data = response.data;
return JSON.parse(data) as UserBody;
}; 🔍🔧🔑 Powered by Code Review GPT |
Test results summary:✅ [PASS] - Test case: Bad variable name SUMMARY: ✅ PASS: 1 - Tests Powered by Code Review GPT |
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions | ||
config.headers["Authorization"] = `Bearer ${session.token}`; |
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 are removing this?
import { useAxios } from "../../../lib/hooks/useAxios"; | ||
import { GetUserProps, UpdateUserProps } from "../../../lib/types"; | ||
|
||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types |
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.
Do we need this?
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 is complaining because we don't have types. I'll add a type now.
@@ -55,7 +55,7 @@ const authOptions: NextAuthOptions = { | |||
async session({ session, token }) { | |||
if (session.user) { | |||
session.user.userId = token.sub; | |||
session.token = token.token; | |||
session.token = token; |
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.
do we need this token now?
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'm not 100% sure on this to be honest. But in my mind we should just remove it because we aren't using tokens at all for the API anymore
Co-authored-by: Matt <[email protected]>
… into feat/user-api # Conflicts: # services/core/helpers/env-helpers.ts
No description provided.