mirror of
https://github.com/ClaytonWWilson/CS307-Team24.git
synced 2026-03-10 13:15:05 +00:00
Merge branch 'master' of github.com:ClaytonWWilson/CS307-Team24
added Navigation bar
This commit is contained in:
@@ -1,27 +1,28 @@
|
||||
const admin = require('firebase-admin');
|
||||
/* eslint-disable promise/always-return */
|
||||
exports.putPost = (req, res) => {
|
||||
if (req.body.body.trim() === '') {
|
||||
return res.status(400).json({ body: 'Body must not be empty!'});
|
||||
}
|
||||
|
||||
|
||||
const newPost = {
|
||||
body: req.body.body,
|
||||
userHandle: req.user.handle,
|
||||
userImage: req.user.imageUrl,
|
||||
userHandle: req.body.userHandle,
|
||||
userImage: req.body.userImage,
|
||||
microBlogTitle: req.body.microBlogTitle,
|
||||
createdAt: new Date().toISOString(),
|
||||
likeCount: 0,
|
||||
commentCount: 0
|
||||
commentCount: 0,
|
||||
|
||||
};
|
||||
|
||||
db.collection('post').add(newPost)
|
||||
.then((doc) => {
|
||||
admin.firestore().collection('posts').add(newPost)
|
||||
.then((doc) => {
|
||||
const resPost = newPost;
|
||||
resPost.postId = doc.id;
|
||||
res.json(resPost);
|
||||
return res.status(200).json(resPost);
|
||||
})
|
||||
.catch((err) => {
|
||||
res.status(500).json({ error: 'something is wrong'});
|
||||
console.error(err);
|
||||
return res.status(500).json({ error: 'something is wrong'});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -10,6 +10,10 @@ exports.getProfileInfo = (req, res) => {
|
||||
db.collection('users').doc(req.user.handle).get()
|
||||
.then((data) => {
|
||||
return res.status(200).json(data.data());
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
return res.status(500).json(err);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -42,7 +46,7 @@ exports.updateProfileInfo = (req, res) => {
|
||||
|
||||
exports.getUserDetails = (req, res) => {
|
||||
let userData = {};
|
||||
db.doc('/users/${req.params.handle}').get().then((doc) => {
|
||||
db.doc(`/users/${req.params.handle}`).get().then((doc) => {
|
||||
if (doc.exists) {
|
||||
userData.user = doc.data();
|
||||
return db.collection('post').where('userHandle', '==', req.params.handle)
|
||||
|
||||
@@ -26,6 +26,7 @@ app.post('/updateProfileInfo', updateProfileInfo);
|
||||
*------------------------------------------------------------------*/
|
||||
const {putPost} = require('./handlers/post');
|
||||
|
||||
|
||||
// Adds one post to the database
|
||||
app.post('/putPost', fbAuth, putPost);
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ const isEmpty = (str) => {
|
||||
};
|
||||
|
||||
const isEmail = (str) => {
|
||||
const emailRegEx = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
||||
const emailRegEx = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
||||
if (str.match(emailRegEx)) return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user