This is a Twitter Clon Back-End with Go and MongoDB. Make Users, Tweets and follow others users.
Download the code and add a .env
file with:
PORT
Port for APIDATABASE_URL
MongoDB URLSECRECT_KEY
Secret password for JWT
execute go mod download
to download the packages and run go run main.go
POST
/registro - Register User Body:
{
"email": "[email protected]",
"password": "*******",
"nombre": "Nombre",
"apellidos": "Apellido",
"fechaNacimiento": "1970-06-30T00:00:00Z"
}
POST
/login - Login User Body:
{
"email": "[email protected]",
"password": "*******"
}
All the next routes require a JWT in the header, like this: Authorization
: Bearer token
GET
/profile?id=ID
- Get Profile InfoPUT
/modifyProfile - Modify Profile Body:
{
"nombre": "nombre",
"apellidos": "apellido",
"biografia": "Biografia",
"ubicacion": "Ciudad, Pais",
"sitioWeb": "www.sitioweb.com",
"fechaNacimiento": "1970-06-30T00:00:00Z"
}
POST
/createRelation?id=ID
- Create relation with other UserDELETE
/deleteRelation?id=ID
- Deleted relation with other UserGET
/requestRelation?id=ID
- Return if exits relation with that userGET
/listUsers?type
=follow&page
=1&search
=something - Get all userstype
:follow
return all the users related.new
return will notpage
: is the batch of users that returns (batch of 20)search
: This is optional search for something with that character
POST
/tweet - Create a Tweet Body:
{
"message": "message"
}
GET
/readTweet?id=ID
&page=1 - return all tweets of one userpage
is the batch of tweets that returns (batch of 20)
DELETE
/deleteTweet?id=ID
- Delete a tweetGET
/mainTweets?page=1 - returns the main tweets of the following peoplepage
is the batch of tweets that returns (batch of 20)
POST
/uploadAvatar - Upload the user avatar must be send a image in a form data with nameavatar
POST
/uploadBanner - Upload the user avatar must be send a image in a form data with namebanner