-
Notifications
You must be signed in to change notification settings - Fork 7
Minor changes #20
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
Minor changes #20
Changes from all commits
34a104e
b8f998d
12835c4
5c0925c
216a703
d2b016f
df481bd
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 | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,7 +1,7 @@ | ||||||||||||||||||||||||||||||||||||||
| import * as projectService from "../services/project.service"; | ||||||||||||||||||||||||||||||||||||||
| import { Request, Response } from "express"; | ||||||||||||||||||||||||||||||||||||||
| import { ApiError } from "../utils/apiError"; | ||||||||||||||||||||||||||||||||||||||
| import { uploadImage } from "../utils/imageUtils"; | ||||||||||||||||||||||||||||||||||||||
| import { deleteImage, uploadImage } from "../utils/imageUtils"; | ||||||||||||||||||||||||||||||||||||||
|
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. 💡 Verification agent 🧩 Analysis chainVerify The pipeline failure indicates that 🏁 Script executed: #!/bin/bash
# Verify deleteImage function exists and is properly exported
echo "Checking if deleteImage function exists in imageUtils:"
ast-grep --pattern 'export $_ deleteImage'
echo "Checking function declarations:"
ast-grep --pattern 'function deleteImage($_) { $$$ }'
ast-grep --pattern 'const deleteImage = $_'Length of output: 338 Implement and Export The import in
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
| import { supabase } from "../app"; | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
|
@@ -16,20 +16,16 @@ export const getProjects = async (req: Request, res: Response) => { | |||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| export const getProjectById = async (req: Request, res: Response) => { | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| const projectId = parseInt(req.params.projectId); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| if (isNaN(projectId)) throw new ApiError("Invalid project ID", 400); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| const project = await projectService.getProjectById(projectId); | ||||||||||||||||||||||||||||||||||||||
| res.status(200).json(project); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| export const createProject = async (req: Request, res: Response) => { | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| const file = req.file; | ||||||||||||||||||||||||||||||||||||||
| if (!file) throw new ApiError('Image file not found', 400); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
|
@@ -43,7 +39,7 @@ export const createProject = async (req: Request, res: Response) => { | |||||||||||||||||||||||||||||||||||||
| name: req.body.projectData.name, | ||||||||||||||||||||||||||||||||||||||
| imageUrl: imageUrl, | ||||||||||||||||||||||||||||||||||||||
| githubUrl: req.body.projectData.githubUrl, | ||||||||||||||||||||||||||||||||||||||
| deployUrl: req.body.deployUrl, | ||||||||||||||||||||||||||||||||||||||
| deployUrl: req.body.projectData.deployUrl, | ||||||||||||||||||||||||||||||||||||||
| AdminId: req.body.projectData.adminId, | ||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
|
@@ -54,24 +50,27 @@ export const createProject = async (req: Request, res: Response) => { | |||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| export const updateProjects = async (req: Request, res: Response) => { | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| const projectInfo = req.body.projectData; | ||||||||||||||||||||||||||||||||||||||
| const projectId = parseInt(req.params.projectId); | ||||||||||||||||||||||||||||||||||||||
| const updatedById = projectInfo.updatedById; | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| let imageUrl = null; | ||||||||||||||||||||||||||||||||||||||
| const file = req.file; | ||||||||||||||||||||||||||||||||||||||
| if( !projectId ) throw new ApiError("ProjectId is missng !!!" , 401); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| if (file) { | ||||||||||||||||||||||||||||||||||||||
| imageUrl = await uploadImage(supabase, file, 'projects'); | ||||||||||||||||||||||||||||||||||||||
| if ( file ) { | ||||||||||||||||||||||||||||||||||||||
| const response = await projectService.getProjectById(projectId); | ||||||||||||||||||||||||||||||||||||||
| const fileUlr = response?.imageUrl; | ||||||||||||||||||||||||||||||||||||||
| if( !fileUlr ) throw new ApiError("File is not exits"); | ||||||||||||||||||||||||||||||||||||||
| imageUrl = await uploadImage(supabase, file, 'projects' , fileUlr); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+59
to
66
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. Fix typos and improve error handling. Several issues need attention:
if ( file ) {
const response = await projectService.getProjectById(projectId);
- const fileUlr = response?.imageUrl;
+ const fileUrl = response?.imageUrl;
- if( !fileUlr ) throw new ApiError("File is not exits");
+ if( !fileUrl ) throw new ApiError("Existing image not found", 404);
- imageUrl = await uploadImage(supabase, file, 'projects' , fileUlr);
+ imageUrl = await uploadImage(supabase, file, 'projects' , fileUrl);
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| if (imageUrl) { | ||||||||||||||||||||||||||||||||||||||
| projectInfo.imageUrl = imageUrl; | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| if (!projectId || projectInfo.length === 0 || !updatedById) throw new ApiError(" Something is Mising ", 400); | ||||||||||||||||||||||||||||||||||||||
| if ( projectInfo.length === 0 || !updatedById) throw new ApiError(" Something is Mising ", 400); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| const project = await projectService.updateProjects(projectInfo, projectId); | ||||||||||||||||||||||||||||||||||||||
| res.status(200).json(project) | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -86,6 +85,13 @@ export const deleteProjects = async (req: Request, res: Response) => { | |||||||||||||||||||||||||||||||||||||
| const projectId = parseInt(req.params.projectId); | ||||||||||||||||||||||||||||||||||||||
| if (!projectId) throw new ApiError(" Send The project id ", 400); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| const response = await projectService.getProjectById(projectId); | ||||||||||||||||||||||||||||||||||||||
| const fileUrl = response?.imageUrl; | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| if(fileUrl){ | ||||||||||||||||||||||||||||||||||||||
| await deleteImage(supabase , fileUrl); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| const deleted = await projectService.deleteProjects(projectId); | ||||||||||||||||||||||||||||||||||||||
| res.status(200).json(deleted) | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
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.
💡 Verification agent
🧩 Analysis chain
Verify deleteImage function exists and is properly exported.
The pipeline failure indicates
deleteImage is not a function, suggesting either the function doesn't exist in the imageUtils module or isn't properly exported.Let me verify the imageUtils implementation:
🏁 Script executed:
Length of output: 447
I want to inspect the full
imageUtils.tsto confirm all exports and see if a default export or other export styles might be conflicting with how tests import/mocking it.🏁 Script executed:
Length of output: 2363
Controller import is correct; update your tests’ mocks for deleteImage
The
deleteImagefunction is properly defined and exported insrc/utils/imageUtils.ts. The runtime error in your pipeline (“deleteImage is not a function”) indicates that your test suite’s mock of theimageUtilsmodule doesn’t include adeleteImagestub. To resolve:• Locate your Jest manual mock for
src/utils/imageUtils(e.g., in__mocks__/src/utils/imageUtils.ts).• Add or export a mock implementation for
deleteImage, for example:• Ensure both
uploadImageanddeleteImageare exported in that mock.With your mocks updated, the controller import will work as expected and the tests should pass.
🤖 Prompt for AI Agents