adding picture display with cloudfront and working on ios take photo and post flow

This commit is contained in:
Will Baumbach
2025-07-30 16:24:09 -05:00
parent 913c4cf3f7
commit e49674a755
9 changed files with 13524 additions and 13450 deletions

View File

@@ -3,6 +3,21 @@ import Post from '../models/postModel.js'
export const getAllPosts = async (req, res, next) => {
const allPosts = await Post.find({}).exec()
allPosts.map((el) => {
el.photo = process.env.CLOUDFRONT_URL + el.photo
})
res.status(200).json({
status: 'success',
data: allPosts
})
}
export const getAllPostsByStatus = async (req, res, next) => {
console.log(req.params.status)
const allPosts = await Post.find({ status: req.params.status }).exec()
allPosts.map((el) => {
el.photo = process.env.CLOUDFRONT_URL + el.photo
})
res.status(200).json({
status: 'success',
data: allPosts
@@ -35,13 +50,14 @@ export const createPost = async (req, res, next) => {
const aws = new AWSUtil()
// Grab base64 photo from the req body
const location = await aws.uploadFile(req.body.photo)
const fileName = await aws.uploadFile(req.body.photo)
const payload = {
...req.body,
photo: location
photo: fileName
}
console.log(payload)
Post.create(payload).then((result) => {
res.status(200).json({
status: 'success',