This repo is intended to be the home for the backend API of the final project for the web engineering course (CC552). Where we, the developers of the project, can illustrate the foundation of this API to provide a seamless integration experience with the client's application. Also, to document our work in a slightly professional manner.
This REST API
is built using Serverless Architecture
with the help of Firebase
and ExpressJS
. This means that the entirety of the express application is running through the Firebase cloud service as a Cloud Function. Obviously, this decision was made to simplify the deployment process as much as possible so that the focus remains on the development of the application itself.
Firebase Authentication
(serving as a secure way to both authenticate and authorise users)Firebase Firestore
(serving as NoSQL datastore of the app)Firebase Cloud Functions
(serving as the host environment of the backend application)Firebase Storage
(serving as the file store of the app)ExpressJS
(serving as the framework used to write the API)TypeScript
(serving as the scripting langues used to write the API)
- To start using this API, an HTTP Request must be made to one of the following endpoints. Make sure to read the notes to insure a issueless integration.
- 🚑 HTTP POST Requests must submit a
Content-Type
ofmultipart/form-data
Some of the requests below are labeled 'Auth Required', these require user authorizing before executing.
'Authorization' : Token
This endpoint is responsible for 3 cases:
POST Request
- There're no request params for this case.
- The request body shall contain a
JSON Object
structured as follows
{
email : string
username : string
birthdate : string
}
{
id : string
email: string
name: string
username: string
avatar : string
coverPhoto : string
bio : string
location : string
birthdate : string
followers : number
following : number
tweetsNo : number
creationDate : string
}
GET Request
Param | Type | Description |
---|---|---|
username |
String | The identifier username for user (@username). |
- There's no request body for this operation.
{
id : string
email: string
name: string
username: string
avatar : string
coverPhoto : string
bio : string
location : string
birthdate : string
followers : number
following : number
tweetsNo : number
creationDate : string
}
PATCH Request
- There're no request params for this case.
Each update should be listed in body object
{
avatar : file
name : string
birthdate : string
}
{
id : string
email: string
name: string
username: string
avatar : string
coverPhoto : string
bio : string
location : string
birthdate : string
followers : number
following : number
tweetsNo : number
creationDate : string
}
This endpoint is responsible for 3 cases:
POST Request
- There're no request params for this case.
- The request body shall contain a
JSON Object
structured as follows
{
text: string // textual content of the tweet
userId: string // the string identifier of the user
hasMedia: boolean // if contains Media, set it to true
mediaType: MediaType // enum representing media type( video, picture, voice)
hasMention: boolean // if it has mentions, pass as true
location: string // string descriping location
timestamp: number // timestamp double number
}
- The
mediaType
enum is structured as follows
//Important to be used in the same order...
enum MediaType {
Video,
Picture,
Audio,
None
}
DELETE Request
Param | Type | Description |
---|---|---|
id |
String | The identifier string of the tweet to delete. |
- There's no request body for this operation.
GET Request
- There're no request params for this case.
- There's no request body for this operation.
This endpoint is responsible for fetching a single tweet's data.
GET Request
Param | Type | Description |
---|---|---|
id |
String | The identifier string of the tweet to load. |
- There's no request body for this operation.
{
"tweetData": {
"replyToPostId": "",
"isRepost": false,
"location": "location",
"repliesCount": 0,
"text": "some valid words",
"postPrivacy": "",
"repostCount": 0,
"mediaContent": {
"image_1": "urlstring"
},
"likesCount": 0,
"userId": "string",
"isReply": false,
"hasMention": "hasMention",
"id": "tweetId",
"timestamp": "1231231231",
"repostToPostId": "",
"mediaType": "2",
"hasMedia": true
},
"tweetReplies": [] //array of tweet objects
}
This endpoint is responsible for loading the tweets of a single user.
GET Request
Param | Type | Description |
---|---|---|
id |
String | The identifier string of the user to load. |
- There's no request body for this operation.
This endpoint is responsible for 2 cases:
POST Request
Param | Type | Description |
---|---|---|
id |
String | The identifier string of the user to follow. |
- No Request body
success or error message
DELETE Request
Param | Type | Description |
---|---|---|
id |
String | The identifier string of the user to unfollow. |
- No Request body
success or error message
GET Request
Param | Type | Description |
---|---|---|
id |
String | The identifier string of the user to get followers for. |
- No Request body
Array of brief user objects
[
{
username,
name,
avatar
},
...
]
GET Request
Param | Type | Description |
---|---|---|
id |
String | The identifier string of the user to get followers for. |
- No Request body
Array of brief user objects
[
{
username,
name,
avatar
},
...
]
GET Request
Param | Type | Description |
---|---|---|
query |
String | The search query string. |
- No Request body
Array of brief user objects
[
{
username,
name,
avatar
},
...
]
This endpoint is responsible for 3 cases:
POST Request
Param | Type | Description |
---|---|---|
tweetId |
String | The string identifying the tweet. |
{
"userId": "someUserId",
"timestamp": Timestamp
}
Delete Request
Param | Type | Description |
---|---|---|
tweetId |
String | The string identifying the tweet to bookmark. |
{
"userId": "someUserId"
}
Delete Request
Param | Type | Description |
---|---|---|
userId |
String | The string identifier of the user to fetch the bookmarks for. |
- No request Body
- An array of
tweet objects
.
[
{
"replyToPostId": "",
"isRepost": false,
"location": "location",
"repliesCount": 0,
"text": "some valid words",
"postPrivacy": "",
"repostCount": 0,
"mediaContent": {
"image_1": "urlstring"
},
"likesCount": 0,
"userId": "string",
"isReply": false,
"hasMention": "hasMention",
"id": "tweetId",
"timestamp": "1231231231",
"repostToPostId": "",
"mediaType": "2",
"hasMedia": true
},...
]
This endpoint is responsible for 2 cases:
POST Request
Param | Type | Description |
---|---|---|
tweetId |
String | The string identifying the tweet to like. |
{
"userId": "someUserId"
}
DELETE Request
Param | Type | Description |
---|---|---|
tweetId |
String | The string identifying the tweet to unlike. |
{
"userId": "someUserId"
}
This endpoint is responsible for fetching the reply tweets of a single tweet.
GET Request
Param | Type | Description |
---|---|---|
tweetId |
String | The string identifier of the tweet to get the replies for. |
- No request body.
- An array of
Tweet objects
[
{
"replyToPostId": "sometweetId", //the id of the tweet the reply was composed for.
"isRepost": false,
"location": "location",
"repliesCount": 0,
"text": "some valid words",
"postPrivacy": "",
"repostCount": 0,
"mediaContent": {
"image_1": "urlstring"
},
"likesCount": 0,
"userId": "string",
"isReply": true,
"hasMention": "hasMention",
"id": "tweetId",
"timestamp": "1231231231",
"repostToPostId": "",
"mediaType": "2",
"hasMedia": true
}
]
This endpoint is responsible for sending a reply to a tweet.
POST Request
Param | Type | Description |
---|---|---|
tweetId |
String | The string identifying the tweet to reply to. |
- An entire
Tweet object
This endpoint is responsible for sending a reply to a tweet.
POST Request
Param | Type | Description |
---|---|---|
tweetId |
String | The string identifying the tweet to retweet. |
- An entire
Tweet object
{
id: string
text: string
userId: string
postPrivacy: string
hasMedia: boolean
mediaType: MediaType
mediaContent: string[]
hasMention: boolean
isRepost: boolean
repostToPostId: string
isReply: boolean
replyToPostId: string
likesCount: number
repliesCount: number
repostCount: number
location: string
timestamp: number
}
{
id : string
email: string
name: string
username: string
avatar : string
coverPhoto : string
bio : string
location : string
birthdate : string
followers : number
following : number
tweetsNo : number
creationDate : string
}