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

Friends #25

Open
wants to merge 175 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
175 commits
Select commit Hold shift + click to select a range
a28b372
Project set up
saritahub Oct 31, 2022
afeabd5
Basic project setup
Arshad-Siddiqui Nov 1, 2022
a0ae2fd
global CSS test
Dmum303 Nov 1, 2022
2c1b954
Added tests for making a post + posting in chronolically reverse orde…
AamirKhanDev Nov 1, 2022
db6093f
Created button in /posts. Need to next implement redirect onclick to …
AamirKhanDev Nov 2, 2022
891454c
Create post form
Arshad-Siddiqui Nov 2, 2022
0a1df4b
Added fork
AamirKhanDev Nov 2, 2022
8e04950
Merge pull request #1 from AamirKhanDev/FLnames
Arshad-Siddiqui Nov 2, 2022
9d6cdb3
Merge branch 'main' of github.com:Dmum303/acebook-team-bikini-bottom …
Arshad-Siddiqui Nov 2, 2022
cf6b377
updated nav bar
piperrosearmstrong Nov 2, 2022
0994eff
navigation bar
Dmum303 Nov 2, 2022
6a7126d
Merge branch 'frontendexplore' of https://github.com/Dmum303/acebook-…
Dmum303 Nov 2, 2022
d7ed6a0
Change textarea to text
Arshad-Siddiqui Nov 2, 2022
62ff91a
Merge branch 'main' of github.com:Dmum303/acebook-team-bikini-bottom
Arshad-Siddiqui Nov 2, 2022
d102844
Merge branch 'main' into frontendexplore
Arshad-Siddiqui Nov 2, 2022
5209c36
Merge pull request #2 from Dmum303/frontendexplore
Arshad-Siddiqui Nov 2, 2022
5009f76
Pulling main
saritahub Nov 2, 2022
f61a908
Created comment file under Models
saritahub Nov 2, 2022
db23d22
Testing comments
saritahub Nov 2, 2022
0e71c4a
Create PostForm component
Arshad-Siddiqui Nov 2, 2022
8cab85b
Add body to PostForm component
Arshad-Siddiqui Nov 2, 2022
253c869
Merge branch 'main' into create_post
Arshad-Siddiqui Nov 2, 2022
6d7aa1c
Editing the comment controller
saritahub Nov 2, 2022
66cdace
Merge branch 'main' into create_post
Arshad-Siddiqui Nov 2, 2022
a9e7bc0
Add Post form to app
Arshad-Siddiqui Nov 2, 2022
18cc74b
Added some test examples for comment model
saritahub Nov 2, 2022
f2c928f
Refactor
saritahub Nov 2, 2022
c173f0f
Amend typo for form event handler
Arshad-Siddiqui Nov 2, 2022
fae45fb
Added date into schema for posts and also added test for date in post…
AamirKhanDev Nov 3, 2022
c72114f
Merge pull request #3 from Dmum303/Testing-with-new-schema
Dmum303 Nov 3, 2022
1d0d908
Add FLnames and timestamps to user schema
Arshad-Siddiqui Nov 3, 2022
f4b9084
Add picture to Users Schema
Arshad-Siddiqui Nov 3, 2022
b1e6794
Removed posts part from comments
saritahub Nov 3, 2022
b555d03
Add fields for first and last names on signup
Arshad-Siddiqui Nov 3, 2022
adeca32
Ammend some tests to check first and last names
Arshad-Siddiqui Nov 3, 2022
f429cf4
Ammend User Spec to check for FL names
Arshad-Siddiqui Nov 3, 2022
58da208
testing comment fields
Dmum303 Nov 3, 2022
3b82dc1
testied user field
Dmum303 Nov 3, 2022
cdd514a
not sure what changed
Dmum303 Nov 3, 2022
3259eb4
Add friends and posts to User Schema
Arshad-Siddiqui Nov 3, 2022
ffd5a25
Merge branch 'main' of github.com:Dmum303/acebook-team-bikini-bottom
Arshad-Siddiqui Nov 3, 2022
482d296
Merge branch 'main' into signup_plus
Arshad-Siddiqui Nov 3, 2022
9cb6d80
Amend all backend tests to use new signup
Arshad-Siddiqui Nov 3, 2022
b66c507
Added post comment tests, currently failing
saritahub Nov 3, 2022
0357816
Post comment test passed
saritahub Nov 3, 2022
7f518f3
Refactored post comment test
saritahub Nov 3, 2022
408149f
Add start of friendslist test
Arshad-Siddiqui Nov 3, 2022
00c6bae
Remove PostForm from being static in app
Arshad-Siddiqui Nov 3, 2022
80e1614
Remove duplicate file
Arshad-Siddiqui Nov 3, 2022
fc44e66
Add PostForm to the bottom of feed
Arshad-Siddiqui Nov 3, 2022
5560e0f
Add authorization to PostForm
Arshad-Siddiqui Nov 3, 2022
5f7bb0c
Fix post requests to make new post
Arshad-Siddiqui Nov 3, 2022
2406bb6
Merge branch 'main' into create_post
Arshad-Siddiqui Nov 3, 2022
973ebdd
Remove unneeded console.log
Arshad-Siddiqui Nov 3, 2022
891b3d8
change to post comment
Dmum303 Nov 3, 2022
69071db
Merge pull request #4 from Dmum303/create_post
Dmum303 Nov 3, 2022
d109d70
Add container around each post
Arshad-Siddiqui Nov 3, 2022
5831765
Merge branch 'main' into signup_plus
Arshad-Siddiqui Nov 3, 2022
69de3cd
Refactor Signup page
Arshad-Siddiqui Nov 3, 2022
cec7449
Create TSConfig file
Arshad-Siddiqui Nov 3, 2022
06340c2
comment test
Dmum303 Nov 3, 2022
ba9259f
Create Signup Form component
Arshad-Siddiqui Nov 3, 2022
313f8bb
Return Signup Form to nav bar
Arshad-Siddiqui Nov 3, 2022
64f5ce5
Format signup page code
Arshad-Siddiqui Nov 3, 2022
9fda105
Re-align logo with sign up form
Arshad-Siddiqui Nov 3, 2022
4fc877d
Add Route for testing components
Arshad-Siddiqui Nov 3, 2022
5203d68
Switch signup form to a class
Arshad-Siddiqui Nov 3, 2022
8f27b6c
Reformat JSX
Arshad-Siddiqui Nov 4, 2022
345f0b8
comment testing
Dmum303 Nov 4, 2022
59fa261
multiple comments tested
Dmum303 Nov 4, 2022
2f1e87c
Create sign up component and implement it on page
Arshad-Siddiqui Nov 4, 2022
329b3f0
working out comment controller
Dmum303 Nov 4, 2022
9cc386f
Remove corrugated iron look
Arshad-Siddiqui Nov 4, 2022
e6d46e3
Merge pull request #5 from Dmum303/signup_plus
saritahub Nov 4, 2022
39ddd57
testing update comment controller
Dmum303 Nov 4, 2022
4dd76b2
Refactor
saritahub Nov 4, 2022
7b45212
Add link between User and their Post
Arshad-Siddiqui Nov 4, 2022
ef45116
Create footer position
Arshad-Siddiqui Nov 4, 2022
b78f8eb
testing update updatecomment bugs
Dmum303 Nov 4, 2022
b415680
testing comment bugs
Dmum303 Nov 4, 2022
83adb6a
stuck with routes
Dmum303 Nov 5, 2022
84efbcc
passed tests for controller to update comment
Dmum303 Nov 6, 2022
3eb1d65
Have added comment with postman
Dmum303 Nov 6, 2022
48ee941
Save files to push
Dmum303 Nov 6, 2022
ef073b4
Post comments backend completed
Dmum303 Nov 7, 2022
39d1a5d
Merge branch 'main' into commentvad
saritahub Nov 7, 2022
6e322e9
Merge pull request #8 from Dmum303/commentvad
Dmum303 Nov 7, 2022
edae257
updated comments con test with new user mod info
Dmum303 Nov 7, 2022
5c5ba01
Merge branch 'main' of github.com:Dmum303/acebook-team-bikini-bottom …
Arshad-Siddiqui Nov 7, 2022
1c30d75
Add timestamps to posts
Arshad-Siddiqui Nov 7, 2022
eb5a969
Improve appearance of PostForm
Arshad-Siddiqui Nov 7, 2022
d4a1489
Post lists reload on submission
Arshad-Siddiqui Nov 7, 2022
a4fd642
Merge branch 'main' into user-to-post
saritahub Nov 7, 2022
8fcfc0f
Merge pull request #9 from Dmum303/commentvad
saritahub Nov 7, 2022
a2c2e28
Merge comments
Arshad-Siddiqui Nov 7, 2022
b00650c
Merge branch 'user-to-post' of github.com:Dmum303/acebook-team-bikini…
Arshad-Siddiqui Nov 7, 2022
e85a3d2
Merge pull request #6 from Dmum303/user-to-post
piperrosearmstrong Nov 7, 2022
2281f53
Fix network errors related to reloads.
Arshad-Siddiqui Nov 7, 2022
4087276
Merge branch 'main' of github.com:Dmum303/acebook-team-bikini-bottom …
Arshad-Siddiqui Nov 7, 2022
4894cd9
Add a container around each post
Arshad-Siddiqui Nov 7, 2022
158f813
Did this commit
Dmum303 Nov 7, 2022
3af3163
Merge pull request #7 from Dmum303/footer
Dmum303 Nov 7, 2022
9b3c774
Comments front end
Dmum303 Nov 7, 2022
68f14f8
Change what is stored in friends array
Arshad-Siddiqui Nov 8, 2022
5d33632
Move sign up form to login page
Arshad-Siddiqui Nov 8, 2022
7dd074b
Add font-awesome to project
Arshad-Siddiqui Nov 8, 2022
3311260
Add logout logo and refresh signup form
Arshad-Siddiqui Nov 8, 2022
7f454da
Change favicon
Arshad-Siddiqui Nov 8, 2022
5dddbca
Comments fronted working
Dmum303 Nov 8, 2022
b730fa8
Merge pull request #10 from Dmum303/footer
Dmum303 Nov 8, 2022
278ce55
minor adj
Dmum303 Nov 8, 2022
382c4d8
Set up friend requests.
Arshad-Siddiqui Nov 8, 2022
6e0ec7c
Likes Model TDD Complete
piperrosearmstrong Nov 8, 2022
378ab4d
Likes Backend Completed
piperrosearmstrong Nov 8, 2022
c43c988
Create working friend request form
Arshad-Siddiqui Nov 8, 2022
193d984
Create backend for friend requests
Arshad-Siddiqui Nov 8, 2022
7420200
minor adj2
Dmum303 Nov 8, 2022
78daeff
comments sorted
Dmum303 Nov 9, 2022
ed08eab
Co-authored-by: Sarita Radia <saritahub@users.noreply.github.com>
Dmum303 Nov 9, 2022
163aa0c
Merge pull request #11 from Dmum303/frontendcomments
Arshad-Siddiqui Nov 9, 2022
106a912
Merged latest main comment/post features, and integrated photo upload
saritahub Nov 9, 2022
d0caeff
Bug: New message form duplicated
saritahub Nov 9, 2022
7e04a56
Merge branch 'main' of https://github.com/Dmum303/acebook-team-bikini…
piperrosearmstrong Nov 9, 2022
a0a225b
Testing PostForm image
saritahub Nov 9, 2022
799411c
Merge pull request #12 from Dmum303/likes3
Arshad-Siddiqui Nov 9, 2022
48b62a7
Reinstalled firebase, duplicated message bug still present
saritahub Nov 9, 2022
ee05c8c
Added CSS for the uploaded image
saritahub Nov 9, 2022
5bacf10
Remove duplicate friends
Arshad-Siddiqui Nov 9, 2022
b93bcde
Remove test route for FriendsForm
Arshad-Siddiqui Nov 9, 2022
c8e7e37
Have logo link to login page
Arshad-Siddiqui Nov 9, 2022
c884f4d
EmbedFriendsForm in Feed
Arshad-Siddiqui Nov 9, 2022
fc4e579
Update class for friends form btn
Arshad-Siddiqui Nov 9, 2022
b24a7ef
Update CSS for previous class change
Arshad-Siddiqui Nov 9, 2022
06d72ca
Fix file names of friends components
Arshad-Siddiqui Nov 9, 2022
4c13e23
Improve consistency between single field forms
Arshad-Siddiqui Nov 9, 2022
8b4ccbe
Add further consistency
Arshad-Siddiqui Nov 9, 2022
0f1d580
Create get Friends route
Arshad-Siddiqui Nov 9, 2022
2d967e0
hide comments complete
Dmum303 Nov 9, 2022
ca7b689
Testing express routes for image upload
saritahub Nov 9, 2022
11ab1aa
Remove unneeded commentForm import
Arshad-Siddiqui Nov 9, 2022
bad4792
messing with css
Dmum303 Nov 9, 2022
1b1f467
Add friendslist to the feed page
Arshad-Siddiqui Nov 9, 2022
184a806
Create friend card
Arshad-Siddiqui Nov 9, 2022
3a6bd9f
Display friends in feed
Arshad-Siddiqui Nov 9, 2022
46fa6d3
start flexbox
Dmum303 Nov 9, 2022
a725a98
Add plus button to form element
Arshad-Siddiqui Nov 9, 2022
44eabb6
Restructure to allow friends to reload
Arshad-Siddiqui Nov 9, 2022
4a3dd6b
Prevent user from adding themselves
Arshad-Siddiqui Nov 9, 2022
41e0781
Migrate signup CSS to main CSS file
Arshad-Siddiqui Nov 9, 2022
ae5ea67
Remove call to unneeded CSS file
Arshad-Siddiqui Nov 9, 2022
09d288a
Create some CSS variables
Arshad-Siddiqui Nov 9, 2022
9c3b456
Switch position of posts and friends
Arshad-Siddiqui Nov 9, 2022
da57a65
Split FriendCard into image and text
Arshad-Siddiqui Nov 9, 2022
54fa100
Add form class to forms
Arshad-Siddiqui Nov 9, 2022
6427c95
Rework CSS for many buttons
Arshad-Siddiqui Nov 9, 2022
cdb8824
Add CSS to friend card
Arshad-Siddiqui Nov 9, 2022
fa5f0e2
Merge branch 'main' of github.com:Dmum303/acebook-team-bikini-bottom …
Arshad-Siddiqui Nov 9, 2022
77c1ea0
Remove duplicate post form
Arshad-Siddiqui Nov 9, 2022
8998500
Add style to post card
Arshad-Siddiqui Nov 9, 2022
0193418
Refactor
saritahub Nov 10, 2022
2d188e2
Photos added to posts
saritahub Nov 10, 2022
f036907
Image style amended
saritahub Nov 10, 2022
bfebbae
next com
Dmum303 Nov 10, 2022
c6f0b08
Add lines between friends
Arshad-Siddiqui Nov 10, 2022
18032e2
Merge branch 'main' into final-photo-upload
Arshad-Siddiqui Nov 10, 2022
773d407
Merge pull request #13 from Dmum303/final-photo-upload
Arshad-Siddiqui Nov 10, 2022
0d6e957
Merge branch 'main' of github.com:Dmum303/acebook-team-bikini-bottom
Arshad-Siddiqui Nov 10, 2022
3dc9b13
Merge branch 'main' into commentstyletest2
Dmum303 Nov 10, 2022
a5188e0
Removed comment from css
Dmum303 Nov 10, 2022
9fb0588
Merge pull request #15 from Dmum303/commentstyletest2
Dmum303 Nov 10, 2022
71e7c71
Merge branch 'main' of github.com:Dmum303/acebook-team-bikini-bottom
Arshad-Siddiqui Nov 10, 2022
4ba4a3f
Merge branch 'main' into friends
Arshad-Siddiqui Nov 10, 2022
f76fc3f
Import Friends component
Arshad-Siddiqui Nov 10, 2022
c983793
Remove duplicate CommentForm
Arshad-Siddiqui Nov 10, 2022
9e8c974
Add form class to form forms
Arshad-Siddiqui Nov 10, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .idea/workspace 2.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}/api/controllers/posts.js"
}
]
}
Empty file added MongoHelp.md
Empty file.
51 changes: 28 additions & 23 deletions api/app.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,38 @@
const createError = require("http-errors");
const express = require("express");
const path = require("path");
const logger = require("morgan");
const JWT = require("jsonwebtoken");
const createError = require('http-errors');
const express = require('express');
const path = require('path');
const logger = require('morgan');
const JWT = require('jsonwebtoken');

const postsRouter = require("./routes/posts");
const tokensRouter = require("./routes/tokens");
const usersRouter = require("./routes/users");
const commentsRouter = require('./routes/comments');
const postsRouter = require('./routes/posts');
const tokensRouter = require('./routes/tokens');
const usersRouter = require('./routes/users');
const friendsRouter = require('./routes/friends');
const likesRouter = require('./routes/likes');

const app = express();

// setup for receiving JSON
app.use(express.json())
app.use(express.json());

app.use(logger("dev"));
app.use(logger('dev'));
app.use(express.json());
app.use(express.static(path.join(__dirname, "public")));
app.use(express.static(path.join(__dirname, 'public')));

// middleware function to check for valid tokens
const tokenChecker = (req, res, next) => {

let token;
const authHeader = req.get("Authorization")
const authHeader = req.get('Authorization');

if(authHeader) {
token = authHeader.slice(7)
if (authHeader) {
token = authHeader.slice(7); // Remove 'bearer' and return the actual token
}

JWT.verify(token, process.env.JWT_SECRET, (err, payload) => {
if(err) {
console.log(err)
res.status(401).json({message: "auth error"});
if (err) {
console.log(err);
res.status(401).json({ message: 'auth error' });
} else {
req.user_id = payload.user_id;
next();
@@ -39,9 +41,12 @@ const tokenChecker = (req, res, next) => {
};

// route setup
app.use("/posts", tokenChecker, postsRouter);
app.use("/tokens", tokensRouter);
app.use("/users", usersRouter);
app.use('/friends', tokenChecker, friendsRouter);
app.use('/comments', tokenChecker, commentsRouter);
app.use('/posts', tokenChecker, postsRouter);
app.use('/tokens', tokensRouter);
app.use('/users', usersRouter);
app.use('/likes', tokenChecker, likesRouter);

// catch 404 and forward to error handler
app.use((req, res, next) => {
@@ -52,10 +57,10 @@ app.use((req, res, next) => {
app.use((err, req, res) => {
// set locals, only providing error in development
res.locals.message = err.message;
res.locals.error = req.app.get("env") === "development" ? err : {};
res.locals.error = req.app.get('env') === 'development' ? err : {};

// respond with details of the error
res.status(err.status || 500).json({message: 'server error'})
res.status(err.status || 500).json({ message: 'server error' });
});

module.exports = app;
23 changes: 23 additions & 0 deletions api/controllers/comments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const Post = require('../models/post');
const TokenGenerator = require('../models/token_generator');

const CommentsController = {
AddComment: (req, res) => {
Post.findByIdAndUpdate(
req.body.id,
{ $push: { comments: { text: req.body.message } } },
{ new: true },
async function (err, docs) {
if (err) {
console.log(err);
} else {
console.log('Updated Post : ', docs);
}
const token = await TokenGenerator.jsonwebtoken(req.user_id);
res.status(201).json({ message: 'OK', token: token });
}
);
},
};

module.exports = CommentsController;
43 changes: 43 additions & 0 deletions api/controllers/friends.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const TokenGenerator = require('../models/token_generator');
const User = require('../models/user');

const FriendsController = {
// Form friend connection
AddFriend: async (req, res) => {
let user = await User.findById(req.user_id)
let friendName = req.body.friend.split(' ')

let potentialFriend = await User.findOne({firstName: friendName[0], lastName: friendName[1]});

const token = await TokenGenerator.jsonwebtoken(req.user_id);

if (!potentialFriend) {
res.status(201).json({ message: 'Friend not found', token: token });
}

else if (user.friends.includes(potentialFriend._id)) {
res.status(201).json({ message: 'They are already friended', token: token });
}

else if (potentialFriend._id.toString() === req.user_id.toString()) {
res.status(201).json({ message: 'You cannot add yourself', token: token });
}

else {
user.friends.push(potentialFriend._id);
user.save();
res.status(201).json({ message: 'OK', token: token });
}
},

GetFriends: async (req, res) => {
let user = await User.findById(req.user_id).populate('friends')
let friends = await user.friends;
console.log('There are the friends', friends)
const token = await TokenGenerator.jsonwebtoken(req.user_id);
res.status(200).json({ friends: friends, token: token });
}
}


module.exports = FriendsController;
47 changes: 47 additions & 0 deletions api/controllers/likes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
const Post = require('../models/post');
const TokenGenerator = require('../models/token_generator');

const LikesController = {
// return all posts
// Index: (req, res) => {
// Post.find(async (err, posts) => {
// if (err) {
// throw err;
// }
// const token = await TokenGenerator.jsonwebtoken(req.user_id);
// res.status(200).json({ posts: posts, token: token });
// });
// },
// create new post
// Create: (req, res) => {
// const post = new Post(req.body);
// post.poster = req.user_id; // Experimental
// post.save(async (err) => {
// if (err) {
// throw err;
// }

// const token = await TokenGenerator.jsonwebtoken(req.user_id);
// res.status(201).json({ message: 'OK', token: token });
// });
// },

Like: (req, res) => {
Post.findByIdAndUpdate(
req.body.id,
{ $push: { likes: { userObj: req.body.userId } } },
{ new: true },
async function (err, docs) {
if (err) {
console.log(err);
} else {
console.log('Updated Post : ', docs);
}
const token = await TokenGenerator.jsonwebtoken(req.user_id);
res.status(201).json({ message: 'OK', token: token });
}
);
},
};

module.exports = LikesController;
15 changes: 11 additions & 4 deletions api/controllers/posts.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
const Post = require("../models/post");
const TokenGenerator = require("../models/token_generator");
const Post = require('../models/post');
const TokenGenerator = require('../models/token_generator');

const PostsController = {
// return all posts
Index: (req, res) => {
Post.find(async (err, posts) => {
if (err) {
throw err;
}
const token = await TokenGenerator.jsonwebtoken(req.user_id)
const token = await TokenGenerator.jsonwebtoken(req.user_id);
res.status(200).json({ posts: posts, token: token });
});
},
// create new post
Create: (req, res) => {
const post = new Post(req.body);
post.poster = req.user_id; // Experimental
post.save(async (err) => {
if (err) {
throw err;
}

const token = await TokenGenerator.jsonwebtoken(req.user_id)
const token = await TokenGenerator.jsonwebtoken(req.user_id);
res.status(201).json({ message: 'OK', token: token });
});
},

// Define a comment (linked to post_id, username or user_id and req.body.comment)
// save comment
// the fetch post reqest req.body.comment assumes that the comment is packaged as object
};

module.exports = PostsController;
1 change: 1 addition & 0 deletions api/controllers/users.js
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ const User = require("../models/user");
const UsersController = {
Create: (req, res) => {
const user = new User(req.body);
console.log(req.body)
user.save((err) => {
if (err) {
res.status(400).json({message: 'Bad request'})
19 changes: 19 additions & 0 deletions api/models/comment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// this is not in use please see posts

const mongoose = require('mongoose');
// Some tutorial videos require 'express',
// commented out as this isn't used in 'post' and 'user'
// const express = require("express-session")

const CommentSchema = new mongoose.Schema({
commentText: { type: String, required: true },
username: { type: String },
// Post commented out for now to keep things simple
// post: { type: mongoose.Schema.Types.ObjectId, ref: 'Post' },
// user: { type: mongoose.Schema.Types.ObjectId, ref: 'User' },
// post_created: { type: Date, default: Date.now }
});

const Comment = mongoose.model('Comment', CommentSchema);

module.exports = Comment;
28 changes: 28 additions & 0 deletions api/models/image.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// const express = require('express')
// const multer = require('multer')
// //importing mongoose schema file
// const Image = require("./image");
// const app = express()
// //setting options for multer
// const storage = multer.memoryStorage();
// const image = multer({ storage: storage });


// const mongoose = require("mongoose");

// const ImageSchema = new mongoose.Schema({
// fileName: {
// type: String,
// required: true,
// },
// file: {
// data: Buffer,
// contentType: String,
// },
// uploadTime: {
// type: Date,
// default: Date.now,
// },
// });

// module.exports = Image = mongoose.model("image", ImageSchema);
Loading