- Profile
- Add Friend
- Post status (Text only)
- View Status of Self + Friend (Use Filter)
- Like and Comment on status
- Add Profile To add a new user profile Sample url – POST - http://localhost:3000/profile Sample Body – { "name":"Aditi", "bio":"", "gender":"F", "phoneno":9999999999, "password":"aditi" }
The api would return userid which we can further use for signin.
-
Signin To login with userid and password Sample url – POST - http://localhost:3000/signin Sample Body – { "userid":1, "password":"aditii" } Upon successful signup a jwt token would be returned. We will have to use this token in headers. Name of the key will be ‘auth_token’ and value would be the token returned by the api. Sample Header – auth_token -eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyaWQiOjEsImlhdCI6MTU4NzgwMDIwMX0.BTHgBGUGSrn5LoJRvUqvT_DhLk32gHUpZzO2G7mpb4E
-
Get Profile To retrieve the user details Sample url – GET - http://localhost:3000/profile Add auth_token generated by signin api
-
Update Profile To update user profile Sample url – PUT - http://localhost:3000/profile Sample Body – { "name":"Aditi", "bio":"", "gender":"F", "phoneno":8888888888, "password":"aditi" } Add auth_token generated by signin api
-
Delete Profile To delete the user profile Sample url – DELETE - http://localhost:3000/profile Sample Body – { "name":"Aditi", "bio":"", "gender":"F", "phoneno":8888888888, "password":"aditi" } Add auth_token generated by signin api
-
Get Friends To get list of all the friends of the user Sample url – GET - http://localhost:3000/friend Add auth_token generated by signin api
-
Add Friends To add a new friend Sample url –POST - http://localhost:3000/friend Sample Body – { "friendid":8 } Add auth_token generated by signin api
-
Delete Friends To delete friend Sample url – DELETE - http://localhost:3000/friend Sample Body – { "friendid":8 } Add auth_token generated by signin api
-
Add Posts To add a post Sample url – POST - http://localhost:3000/posts Sample Body – { "txt":"New Post Added" } Add auth_token generated by signin api
-
Update Posts To update a post Sample url – PUT - http://localhost:3000/posts Sample Body – { "txt":"Post Updated" } Add auth_token generated by signin api
-
Delete Posts To delete the posts Sample url – DELETE - http://localhost:3000/posts Sample Body – { "id":"5ea311ca0a644e4bb0017d7a" } Add auth_token generated by signin api
-
View Post of self+ friends To view status based on filter. Filtered value will be passed in body as array. If empty, only status posted by logged in user would be visible. Sample url – POST - http://localhost:3000/posts Sample Body – { "id":"5ea311ca0a644e4bb0017d7a" } Add auth_token generated by signin api
-
Like Posts To like the post Sample url – POST - http://localhost:3000/posts/likepost { "id":"5ea3f59801e97850106d7ab5" } Add auth_token generated by signin api
-
Comment on Posts To comment on the post Sample url – POST - http://localhost:3000/posts/commentonpost { "id":"5ea3f59801e97850106d7ab5", "comment":"Great" } Add auth_token generated by signin api
- Create Profile Table –
CREATE TABLE profile ( userid integer NOT NULL DEFAULT nextval('your_seq'::regclass), name character varying(30) COLLATE pg_catalog."default" NOT NULL, bio text COLLATE pg_catalog."default", gender "char", phoneno numeric, password character varying(30) COLLATE pg_catalog."default" NOT NULL, CONSTRAINT profile_pkey PRIMARY KEY (userid) )
-
Create Friends table - CREATE TABLE friends ( userid integer NOT NULL, friendid integer NOT NULL, CONSTRAINT friend_pkey PRIMARY KEY (userid, friendid), CONSTRAINT friends_friendid_fkey FOREIGN KEY (friendid) REFERENCES profile (userid) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION, CONSTRAINT friends_userid_fkey FOREIGN KEY (userid) REFERENCES profile (userid) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION )
-
Insert Data in Profile table-
INSERT INTO profile(name, bio, gender, phoneno, password) VALUES ('Aditi', '', 'F', 9999999999, 'adi'); INSERT INTO profile(name, bio, gender, phoneno, password) VALUES ('Arti', '', 'F', 9999999999, 'xyz'); INSERT INTO profile(name, bio, gender, phoneno, password) VALUES ('Ashu', '', 'M', 9999999999, 'yzxx');
- Insert data query for Friends table –
INSERT INTO friends(userid, friendid) VALUES (1,2)
Use test db Insert query for collection posts – db.posts.insert({userid:1,post_text:”New Post”,like:[],comment:[]}) db.posts.insert({userid:1,post_text:”Another Post”,like:[],comment:[]})