Skip to content

An API to simulate a social network where members can friend each other.

Notifications You must be signed in to change notification settings

eest12/Social-Network-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Social Network API

An API to simulate a social network where members can friend each other. Uses Express and a file system for data storage.

Setup

Install Node dependencies:

npm install

Start server on localhost:3000:

npm run start

HTTP Routes

Path Method Description
/members GET Get all members
/member/:id GET Get member
DELETE Delete member and all friendships associated with it
/member/:id/friends GET Get member's friends
/member/:id1/friend/:id2 GET Get member's friend (or empty set if the two members are not friends)
POST Add member as friend
DELETE Remove member as friend
/member/:id/feed GET Get member feed consisting of friends' statuses
/register POST Create new member

Data

The data directory contains two files: members.json and friendships.json.

Members

The members.json file contains mock data that was generated using Mockaroo. It contains 50 rows and these fields (using Mockaroo's attributes):

Field Name Type
id Row Number (Primary Key)
username Username
first_name First Name
last_name Last Name
email Email Address
gender Gender
birthdate Datetime
avatar Avatar
status Sentences

Friendships

The friendships.json file was generated using the src/friends-script.js script. It consists of randomly assigned friendships between the members in members.json. A friendship is denoted by the key-value pair member1_id: member2_id. The fields look like this:

Field Name Type
member1_id Row Number (Foreign Key)
member2_id Row Number (Foreign Key)

The following command can be used to generate new friendships:

node src/friends-script.js [max_friends]

The optional max_friends argument specifies the maximum number of friends a single member can have. The default value is 25.

About

An API to simulate a social network where members can friend each other.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published