-
Notifications
You must be signed in to change notification settings - Fork 4
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
base: main
Are you sure you want to change the base?
Conversation
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.
Hey Luke, thanks for making this API for image upload. I've got some feedback:
- Would it be possible to move the db credentials into a secrets file? Generally it's good practice to not include credentials in code.
- Can you add a route that allows me to fetch images associated with a given tree?
- 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; |
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.
tree_image should be camelCase
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 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(); |
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.
so tree id goes in to this
imageuploadRouter.get('/image/:filename', (req, res) => { | ||
const loaded = false; | ||
const { filename } = req.params; | ||
if(loaded === false){ |
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.
@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.
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.
That'd old and I need to remove that
const dataInSnakeCase = convertObjectKeysToSnakeCase(source); | ||
|
||
const query = ` | ||
INSERT INTO tree_images(\${this:name}) |
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 needs to be create image where id is specific id
return results; | ||
} | ||
|
||
export async function getAllImages() { |
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.
will also need a getAllImagesById query
Added the backend route for the image upload feature. Needs the database table name and route name.