This application is a simple social network using Node.js and MySQL. The user interface is based on command line. And there are a couple of commands available to realize basic interactions on a social network.
Node.jswith version >= 8.0 andnpmwith version >= 5.0, latest version recommendedMySQLwith version 8.0
- The steps to install
Node.json macOS can be found in the link => Install Node.js on macOS. - The steps to install
Node.json Debian and Ubuntu based Linux distributions can be found in the link => Install Node.js on Debian/Ubuntu. - For other OS, follow this link => Install Node.js. Windows is not recommended.
- Check if Node.js is installed and its version by using command
node -v. - Check if npm is installed and its version by using command
npm -v.
- The steps to install
MySQL 8.0can be found in the link => Install MySQL 8.0.
-
Ensure
MySQLis running somewhere. -
Create database by sourcing
sn_204_G8.sql. (sample data is provided in the SQL file and will be inserted) -
Ensure the working directory is the root directory of the project in which there is a file called
package.json. -
Run
npm installto restore the dependencies. -
Run
npm linkto link the package. -
Run
chmod +x sng8/sng8.jsto add permission. -
(Important) Replace
username,password,host,portinmysql-config.jsonwith yours. -
(Important) You probably need do following in
MySQLif there is a connection issue.ALTER USER '<your user>'@'localhost' IDENTIFIED BY '<your password>'; ALTER USER '<your user>'@'localhost' IDENTIFIED WITH mysql_native_password BY '<your password>'; flush privileges;
- A person can initial a post on a topic.
- A person can join a group with another person.
- A person can follow a topic.
- A person can determine what posts have been added by people and/or topics that they are following since they last read from those people/topics.
- A person can respond to a post with thumbs up and/or a response post.
sng8, which stands for social network group 8.- note: ensure you follow the setup.
- In case that
sng8does not work: usesng8/sng8.js
list(alias:ls), list all entries in an entity table, such as Users -u, Posts -p, Topics -t or Groups -gshow, show the relationship a user -u has, such as following users -f, following topics -t or joined groups -gpost(alias:po), create a new post with author -u, topic -t and content -c, or respond to a read/own post with author -u, post ID -p and content -cfollow(alias:fo), follow a user with user -u and following user -f, or follow a topic with user -u and topic -t, or join a group with user -u and group name -gunfollow(alias:unfo), unfollow a followed user with user -u and following user -f, or unfollow a followed topic with user -u and topic -t, or leave an joined group with user -u and group name -gfetch(alias:fch), fetch new posts from following user with user -u and following user -f, or fetch new posts from following topic with user -u and following topic -tread, read a specific post with user -u and post ID -plike, like a read/own post with user -u and post ID -punlike, unlike a liked post with user -u and post ID -pcreate, create a new user with username -u, email -e, name -n and birth date -b
list all entries in an entity table, such as Users -u, Posts -p, Topics -t or Groups -g
-
sng8 list -u:- list all entries in
Userstable.
- list all entries in
-
sng8 ls -p:- list all entries in
Poststable.
- list all entries in
-
sng8 list -t:- list all entries in
Topicstable.
- list all entries in
-
sng8 ls -g:- list all entries in
Groupstable.
- list all entries in
show the relationship a user -u has, such as following users -f, following topics -t or joined groups -g
-
sng8 show -u 'user5' -f:-
show all the users that
user5is following. -
sample output:
- userId: 2 userName: user1 email: user1@sn.com name: user1 birthDate: Fri Aug 21 1981 00:00:00 GMT-0400 (Eastern Daylight Time) - ...
-
-
sng8 show -u 'user3' -t:-
show all the topics that
user3is following. -
sample output:
- topicId: 4 topicName: Music - topicId: 5 topicName: Fashion - topicId: 6 topicName: Politics
-
-
sng8 show -u 'user3' -g:-
show all the groups that
user3has joined. -
sample output:
- groupId: 4 groupName: Group 4 createdBy: 3 - groupId: 5 groupName: Group 5 createdBy: 3 - ...
-
create a new post with author -u, topic -t and content -c, or respond to a read/own post with author -u, post ID -p and content -c
-
sng8 post -u 'user2' -t 'Business' -c 'This is a post.':-
user2creates a new post on topicBusinesswith contentThis is a post.. -
sample output:
Post #7 has been successfully created!
-
-
sng8 post -u 'user5' -p 7 -c 'This is a response to an unread post.':-
user5tries to respond an unread post #7 created by another user with contentThis is a response to an unread post.. -
post not owned by the user must be read before responding, see read sample usage section below.
-
sample output:
User 'user5' has not read post #7 yet!
-
-
sng8 po -u 'user2' -p 7 -c 'This is a response.':-
user2responds to a read/own post #7 with contentThis is a response.. -
sample output:
Response #8 has been successfully created!
-
follow/unfollow a user with user -u and following user -f, or follow/unfollow a topic with user -u and topic -t, or join/leave a group with user -u and group name -g
-
sng8 fo -u 'user1' -f 'user2':-
user1follows useruser2. -
sample output:
User 'user1' has successfully followed user 'user2'!
-
-
sng8 unfo -u 'user1' -f 'user2':-
user1unfollows useruser2. -
sample output:
User 'user1' has successfully unfollowed user 'user2'!
-
-
sng8 fo -u 'user1' -t 'Sports':-
user1follows topicSports. -
sample output:
User 'user1' has successfully followed topic 'Sports'!
-
-
sng8 unfo -u 'user1' -t 'Sports':-
user1unfollows topicSports. -
sample output:
User 'user1' has successfully unfollowed topic 'Sports'!
-
-
sng8 fo -u 'user4' -g 'Group 2':-
user4joins groupGroup 2. -
sample output:
User 'user4' has successfully joined group 'Group 2'!
-
-
sng8 unfo -u 'user4' -g 'Group 2':-
user4leaves groupGroup 2. -
sample output:
User 'user4' has successfully left group 'Group 2'!
-
fetch new posts from following user with user -u and following user -f, or fetch new posts from following topic with user -u and following topic -t
-
sng8 fch -u 'user3' -f 'user2':-
user3fetches new posts from following useruser2and mark as read. -
sample output:
- topicName: Technology parentPostId: 1 postId: 2 type: text content: This is post #2. The delayed leisure consumes a lighted controller. The gang works a practical treasure. An upset consumer dashes behind the integrated predecessor. The upward voltage scores. likes: 2 - ...
-
-
sng8 fch -u 'user2' -t 'Music':-
user2fetches new posts from following topicMusicand mark as read. -
sample output:
- author: user4 parentPostId: 4 postId: 5 type: text content: This is post #5. A vocal boggles next to the unconvincing worship. Without the origin hopes the unifying collar. The attractive gateway captures the nest. His sales philosophy prosecutes. A bush results on top of a conference! likes: 2
-
read a specific post with user -u and post ID -p, like a read/own post with user -u and post ID -p, unlike a liked post with user -u and post ID -p
-
sng8 read -u 'user1' -p 8:-
user1reads post #8, mark the post as read if the reader is NOT author and the post has NOT been read. -
sample output:
- author: user2 topicName: Business parentPostId: 7 postId: 8 type: text content: This is a response. likes: 0
-
-
sng8 like -u 'user1' -p 8:-
user1likes post #8 if the user is author or the post has been read. -
sample output:
User 'user1' has successfully liked post #8! -
note: call
sng8 read -u 'user1' -p 8again to see the increment oflikes.
-
-
sng8 unlike -u 'user1' -p 8:-
user1unlikes post #8 if the post has been liked. -
sample output:
User 'user1' has successfully unliked post #8! -
note: call
sng8 read -u 'user1' -p 8again to see the decrement oflikes.
-
create a new user with username -u, email -e, name -n and birth date -b
sng8 create -u 'newuser' -e 'nu@sn.com' -n 'newuser' -b '1987/06/15':-
create a new user with username
newuser, emailnu@sn.com, namenewuserand birth date1987/06/15. -
notes:
usernamemust be unique.emailmust be unique and valid.birth datemust be valid.
-
sample output:
User 'newuser' has been successfully created!
-
- This application does not support creating new topic/group.
- This application does not support title for posts.
- This application does not support user authentication.
- Available data in database:
-
existing users:
- userId: 1 userName: admin email: admin@sn.com name: admin birthDate: Sun Jul 20 1980 00:00:00 GMT-0400 (Eastern Daylight Time) - userId: 2 userName: user1 email: user1@sn.com name: user1 birthDate: Fri Aug 21 1981 00:00:00 GMT-0400 (Eastern Daylight Time) - userId: 3 userName: user2 email: user2@sn.com name: user2 birthDate: Wed Sep 22 1982 00:00:00 GMT-0400 (Eastern Daylight Time) - userId: 4 userName: user3 email: user3@sn.com name: user3 birthDate: Sun Oct 23 1983 00:00:00 GMT-0400 (Eastern Daylight Time) - userId: 5 userName: user4 email: user4@sn.com name: user4 birthDate: Sat Nov 24 1984 00:00:00 GMT-0500 (Eastern Standard Time) - userId: 6 userName: user5 email: user5@sn.com name: user5 birthDate: Wed Dec 25 1985 00:00:00 GMT-0500 (Eastern Standard Time) - userId: 7 userName: nu1 email: nu1@sn.com name: newUser1 birthDate: Sun Jan 26 1986 00:00:00 GMT-0500 (Eastern Standard Time)
-
existing posts:
- postId: 1 content: This is post #1. The artist explodes in a slice. Near the platform waits the pleased well. The shirt beams the limb outside a hated constraint. A sector flowers after a competitive focus. A mystery hums opposite its populace. type: text userId: 2 - postId: 2 content: This is post #2. The delayed leisure consumes a lighted controller. The gang works a practical treasure. An upset consumer dashes behind the integrated predecessor. The upward voltage scores. type: text userId: 3 - postId: 3 content: This is post #3. The behind employer suffers next to the clothed cliff. The yeti rolls after a north. When can the displayed harden mature outside the anecdote? An indicator braves an adventure. type: text userId: 4 - postId: 4 content: This is post #4. The psychologist puzzles? Does the diet stretch the lunatic? A dust returns around the enemy. The resigned mechanism hunts near the newest invalid. A constitutional knights the bitmap. type: text userId: 4 - postId: 5 content: This is post #5. A vocal boggles next to the unconvincing worship. Without the origin hopes the unifying collar. The attractive gateway captures the nest. His sales philosophy prosecutes. A bush results on top of a conference! type: text userId: 5 - postId: 6 content: This is post #6. How can a cash clog above the medium bath? A religious jet gowns the sentient. My priced fog mends. A neutral lisp promises the menu. type: text userId: 5
-
available topics:
- topicId: 1 topicName: Technology - topicId: 2 topicName: Business - topicId: 3 topicName: Sports - topicId: 4 topicName: Music - topicId: 5 topicName: Fashion - topicId: 6 topicName: Politics
-
available groups:
- groupId: 1 groupName: Group 1 createdBy: 2 - groupId: 2 groupName: Group 2 createdBy: 2 - groupId: 3 groupName: Group 3 createdBy: 2 - groupId: 4 groupName: Group 4 createdBy: 3 - groupId: 5 groupName: Group 5 createdBy: 3 - groupId: 6 groupName: Group 6 createdBy: 4
-