Skip to content

Latest commit

 

History

History
202 lines (121 loc) · 8.11 KB

README.md

File metadata and controls

202 lines (121 loc) · 8.11 KB

Linkr ⛓️

Share and tag links!

💻 Tech used

Overview

This is the API with which the Linktr App interacts.

🛠️ Installation

Make sure you have the following tools installed before you begin:

Not needed but recommended: VSCode

This API was designed to work with Linktr App

Use a terminal interface such as bash or zsh, and enter the following:

#download
gh repo clone blarth/linktr-api

#access the folder you downloaded it to
cd linktr-api

#install dependencies
npm i

The app will run locally and you must configure a .env file with a port of your choosing. The default one is 3000.

⚙️Running

#you can run the server with
npm run dev

In another terminal instance, run the db

#you can start the db with
psql

📜Documentation

All requests are HTTP based

POST /signup, /signin, DELETE /signout

Authenticating related routes. Send requests of the respective types with the following:

To signup:

{

email: any email,
password: no restrictions, it will be stored encrypted,
username: name with which the user will be identified,
image: link to an image file, it will be shown as the user's avatar, supported extensions are png, jpg, jpeg, jfif, gif

}

To signin:

{

email: email used to signup,
password: password chosen upon signup

}

The server will respond with a token, to be used on every other route where authetication is required. Use in the headers of your requests as:

{

Authorization: Bearer <GIVEN_TOKEN>

}

To signout, simply send the request with a header containing the Authorization key above.

GET /users

Send the request with auth header to get info about you, like profile picture and name.

GET /timeline:offset?, /hashtags, POST /timeline

Get timeline route with optional offset parameter, other routes without params.

With the auth header, send the request to timeline to get the ten last posts from users you follow, including their reposts, most recent first, and hashtags, to get the trending hashtags, ten most used first. The optional parameter lets you offset messages to get starting from the n-th last message. To post a link, send request to timeline, as a logged user, with the following:

{

link: the link you want to share,
postText: the text to give it context, you can post hashtags by using # before a word.

}

POST /users/follow

To follow a user, send the request with the auth and a body with:

{

followedUserId: id of user you want to follow

}

GET /users/following

With the auth header, get all users you're following.

Resquests with params:

GET /users/follow/:id

The request is used to check if user with id <:ID> is your follower.

PUT /posts/:id/:status

Send a request with the post id and the current status it has, liked or not. The server will like the post or remove it, adding or removing your user from the list of people who liked it.

GET /posts/hashtags/:name

Get all posts containing the <:NAME> hashtag (without the #)

GET /posts/user/:name

Get all posts from user <:NAME>

DELETE /deletepost/:id

As a logged user and publisher of the post, send the request to delete it, with the id given.

PATCH /posts/edit/:id

As a logged user and publisher of the post, you can edit it by sending a request with it's id. Any hashtags removed will lose a score in the trending ranking, any added will gain a score, and remaining ones are unaltered.

GET /likes/:id

Get all likes from post with id <:ID>

GET /users/:id

Get all posts from user's id <:ID>

GET and POST /comments/:id

As a logged user, with the auth header setting, get the comments from post with <:ID>, info about commentator, such as if it's the original post's author or if it's followed by the logged user is also present. To post, send a request with the auth header shown above and a body with:

{

comment: your comment

}

GET and POST /repost/:id

Send the post request with the auth header and the post's id to mark the post as reposted by you. You follower's will be able to see it if they don't follow the original poster and all comments of the original post are loaded. You'll also increase the repost count of that post.

To check whether it has been reposted or not, send the get request.

GET searchbar/:name

Get all users with names starting with <:NAME>, as a logged user, the people you follow being shown up first.

👨‍💻 Authors

Made with care by

João Marcos Inocente

Gmail Badge

Linkedin Badge

Felipe Ventura

Gmail Badge

Linkedin Badge

Rayane Ventura

Gmail Badge

Linkedin Badge

Lucas Tadeu

Gmail Badge

Linkedin Badge

Contact us anytime!