Build your own not-quite-Twitter!
The project is structured as follows:
index.ts
sets up the database connection and the Express server/freet
contains files related to freet conceptcollection.ts
contains freet collection class to wrap around MongoDB databasemiddleware.ts
contains freet middlewaremodel.ts
contains definition of freet datatyperouter.ts
contains backend freet routesutil.ts
contains freet utility functions for transforming data returned to the client
/user
contains files related to user conceptcollection.ts
contains user collection class to wrap around MongoDB databasemiddleware.ts
contains user middlewaremodel.ts
- contains definition of user datatyperouter.ts
- contains backend user routesutil.ts
contains user utility functions for transforming data returned to the client
/profile
contains files related to profile conceptcollection.ts
contains profile collection class to wrap around MongoDB databasemiddleware.ts
contains profile middlewaremodel.ts
- contains definition of profile datatyperouter.ts
- contains backend profile routesutil.ts
contains profile utility functions for transforming data returned to the client
/interaction
contains files related to interaction conceptcollection.ts
contains interaction collection class to wrap around MongoDB databasemiddleware.ts
contains interaction middlewaremodel.ts
- contains definition of interaction datatyperouter.ts
- contains backend interaction routesutil.ts
contains interaction utility functions for transforming data returned to the client
/following
contains files related to following conceptcollection.ts
contains following collection class to wrap around MongoDB databasemiddleware.ts
contains following middlewaremodel.ts
- contains definition of following datatyperouter.ts
- contains backend following routesutil.ts
contains following utility functions for transforming data returned to the client
/follower_barrier
contains files related to follower barrier conceptcollection.ts
contains follower barrier collection class to wrap around MongoDB databasemiddleware.ts
contains follower barrier middlewaremodel.ts
- contains definition of follower barrier datatyperouter.ts
- contains backend follower barrier routesutil.ts
contains follower barrier utility functions for transforming data returned to the client
/public
contains the code for the frontend (HTML/CSS/browser JS)
The following api routes have already been implemented for you :
GET /
- This renders the
index.html
file that will be used to interact with the backend
- This renders the
-
GET /api/freets
- Get all the freets- Returns
- An array of all freets sorted in descending order by date modified
- Returns
-
GET /api/freets?authorId=id
- Get freets by authorId- Returns
- An array of freets created by user with username
author
- An array of freets created by user with username
- Throws
400
ifauthor
is not given404
ifauthor
is not a recognized username of any user
- Returns
-
POST /api/freets
- Create a new freet- Body
content
{string} - The content of the freet
- Returns
- A success message
- A object with the created freet
- Throws
403
if the user is not logged in400
If the freet content is empty or a stream of empty spaces413
If the freet content is more than 140 characters long
- Body
-
DELETE /api/freets/:freetId?
- Delete an existing freet- Returns
- A success message
- Throws
403
if the user is not logged in403
if the user is not the author of the freet404
if the freetId is invalid
- Returns
-
PUT /api/freets/:freetId?
- Update an existing freet- Body
content
{string} - The new content of the freet
- Returns
- A success message
- An object with the updated freet
- Throws
403
if the user is not logged in404
if the freetId is invalid403
if the user is not the author of the freet400
if the new freet content is empty or a stream of empty spaces413
if the new freet content is more than 140 characters long
- Body
POST /api/users/session
- Sign in user- Body
username
{string} - The user's usernamepassword
{string} - The user's password
- Returns
- A success message
- An object with user's details (without password) -Throws
403
if the user is already logged in400
if username or password is not in correct format format or missing in the req401
if the user login credentials are invalid
- Body
DELETE /api/users/session
- Sign out user- Returns
- A success message
- Throws
403
if user is not logged in
- Returns
POST /api/users
- Create an new user account- Body
username
{string} - The user's usernamepassword
{string} - The user's password
- Returns
- A success message
- An object with the created user's details (without password)
- Throws
403
if there is a user already logged in400
if username or password is in the wrong format409
if username is already in use
- Body
PUT /api/users
- Update a user's profile- Body (no need to add fields that are not being changed)
username
{string} - The user's usernamepassword
{string} - The user's password
- Returns
- A success message
- An object with the update user details (without password)
- Throws
403
if the user is not logged in400
if username or password is in the wrong format409
if the username is already in use
- Body (no need to add fields that are not being changed)
DELETE /api/users
- Delete user- Returns
- A success message
- Throws
403
if the user is not logged in
- Returns
POST /api/profile
- Create an new user profile- Body
username
{string} - The user profile usernamepicture
{string} - The user's profile picturebio
{string} - The user's profile bio
- Returns
- A success message
- A profile with the created user's details
- Throws
403
if the user is not logged in409
if username is already in use413
if the bio is more than 140 characters long
- Body
PUT /api/profile
- Update profile bio for given user profile- Body (no need to add fields that are not being changed)
bio
{string} - The user's new profile biopicture
{string} - The user's new profile picture
- Returns
- A success message
- An object with the updated profile
- Throws
403
if the user is not logged in400
if the new bio/picture content is empty or a stream of empty spaces413
if the new bio content is more than 140 characters long
- Body (no need to add fields that are not being changed)
DELETE /api/profile
- Delete user profile- Returns
- A success message
- Throws
403
if the user is not logged in
- Returns
GET /api/interaction
- Get all the interactions- Returns
- An array of all the interactions in the database
- Returns
GET /api/interaction?freetId=id
- Get interactions by freetID.- Returns
- An array of interactions created by freet with id,
freetId
- An array of interactions created by freet with id,
- Throws
400
If freetId is not given403
If the user is not logged in404
If freet with freetId does not exist
- Returns
DELETE /api/freet_interaction/:interactionId
- Delete an interaction- Returns
- A success message
- Throws
403
If the user is not logged in or is not the author of the interaction404
ifinteractionId
does not exist
- Returns
POST /api/interaction
- Create an interaction- Body
type
{string} - The interaction typeauthorId
{string} - The user profile usernamefreetId
{string} - The freet IDcontent
{string} - If of type 'reply' then the content otherwise empty
- Returns
- A success message
- An object with the created interaction
- Throws
403
if the user is not logged in404
ifauthorId
is not a recognized username of any user404
iffreetId
is invalid404
iftype
is not a recognized type of interaction413
if the new freet interaction content is more than 140 characters long
- Body
PUT /api/interaction/:interactionId?
- Update an existing interaction- Body
content
{string} - The new content of the reply interaction
- Returns
- A success message
- An object with the updated interaction
- Throws
403
if the user is not logged in404
if the interactionId is invalid403
if the user is not the author of the freet400
if the new freet interaction content is empty or a stream of empty spaces413
if the new freet interaction content is more than 140 characters long
- Body
DELETE /api/following/:following?
- Delete a following- Returns
- A success message
- Throws
403
if the user is not logged in403
if the user does not already followfollower
403
if the user is trying to unfollow itself404
if follower/user is not a recognized username of any user
- Returns
POST /api/following
- Create a following- Body (no need to add fields that may not be needed like the passocde)
following
{string} - username who is being followedpasscode
{string} - passcode needed to follow if user has a follower barrier
- Returns
- A success message
- An object with the created following
- Throws
403
if the user is not logged in400
if the user has a follower barrier and is missing the passcode401
if the user has a follower barrier and entered the wrong credentials403
if the user is trying to follow itself403
if the user already followsfollowing
404
iffollowing
is not a recognized username of any user404
if user is not a recognized username of any user
- Body (no need to add fields that may not be needed like the passocde)
GET /api/following/following
- Get all the users you are following- Returns
- A success message
- A list of all the users you follow
- Throws
403
if the user is not logged in404
if user is not a recognized username of any user
- Returns
GET /api/following/followers
- Get all the users that you follow- Returns
- A success message
- A list of all the users following you
- Throws
403
if the user is not logged in404
if user is not a recognized username of any user
- Returns
POST /api/follower_barrier
- Turn on fbState- Body
username
{string} - username who is turning on fbStatepasscode
{string} - passcode needed to follow a user
- Returns
- A success message
- An object with the created follower barrier
- Throws
403
if the userusername
is not logged in404
if user is not a recognized username of any user400
if the new passcode is empty or a stream of empty spaces413
if the new passcode is more than 15 characters long
- Body
DELETE /api/follower_barrier
- Turn off fbState- Returns
- A success message
- Throws
403
if the user is not logged in or the follower barrier does not exist
- Returns
PUT /api/follower_barrier
- Update passcode- Body
passcode
{string} - The new passcode
- Returns
- A success message
- An object with the updated follower barrier
- Throws
403
if the user is not logged in404
if user is not a recognized username of any user400
if the new passcode is empty or a stream of empty spaces413
if the new passcode is more than 15 characters long
- Body