Skip to content
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

spicyTuna/feature/image-upload #146

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Spicytuna24
Copy link

Added the backend route for the image upload feature. Needs the database table name and route name.

Copy link

@PGrad PGrad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Luke, thanks for making this API for image upload. I've got some feedback:

  1. Would it be possible to move the db credentials into a secrets file? Generally it's good practice to not include credentials in code.
  2. Can you add a route that allows me to fetch images associated with a given tree?
  3. Please make sure to run the linter on your code (and follow the Code Conventions here).


//Change the route to 'idk' just change from filenumber
treeimagesRouter.get('/treeimage/:filenumber', async (req, res) => {
const { idImage, tree_images } = req.query;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tree_image should be camelCase

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to add id as a parameter for the tree since its getting images for that specific tree

const { idImage, tree_images } = req.query;

if (!idImage && tree_images === 'All') {
let foundImages = await getAllImages();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so tree id goes in to this

imageuploadRouter.get('/image/:filename', (req, res) => {
const loaded = false;
const { filename } = req.params;
if(loaded === false){
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Spicytuna24 is this if statement supposed to be here? I see you're checking if loaded is false when it was already set as such two lines above.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That'd old and I need to remove that

const dataInSnakeCase = convertObjectKeysToSnakeCase(source);

const query = `
INSERT INTO tree_images(\${this:name})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be create image where id is specific id

return results;
}

export async function getAllImages() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will also need a getAllImagesById query

@Spicytuna24 Spicytuna24 changed the title added image upload route spicyTuna/features/image-upload Jul 26, 2023
@Spicytuna24 Spicytuna24 changed the title spicyTuna/features/image-upload spicyTuna/feature/image-upload Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Help Wanted
Development

Successfully merging this pull request may close these issues.

None yet

3 participants