Skip to content

marinaescriva/Backend-redsocial-hi-its-me

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hi its me!

This app is a social tool modeled after Instagram, allowing users to post text updates in the feed and engage with posts by giving likes.

Index

Deploy

Installation

Functionalities

Tech

  • JavaScript
  • MongoDB
  • JWT
  • Node.js
  • Express.js

Data Base

This app have users and posts related each other.

DataBase

Objective 📌

The application is a social networking platform focused on facilitating post sharing and interaction among users. Users have the ability to create posts, edit their own posts, and engage with posts created by other users by liking or disliking them. Additionally, users can explore a feed of posts from other users, providing a space for communication and expression within the community.

Deploy 🚀

https://hi-its-me-dev-sjmz.2.sg-1.fl0.io

🔧 Installation

  • Initial steps to run the proyect
  • Clone de repository
  • Install dependencies
$ npm install
  • Create a container in Docker with your credentials.
  • Create the .env file and define your personal credentials to run the project.
  • Run de seeder:
$ npm run seed
  • Initialize API
$ npm run dev
$ npm init --yes
$ npm i express
$ npm i nodemon -D 
$ npm dotenv -E
$ npm i mongoose -E
  • installation Git
$ git init

  • Add type module to do import and export (avoid use "requires")
//(on package.json) 
//write before scripts:

{
    "type":"module"
}
npm i mongoose

🔨 Functionalities

  • Auth endpoints
  • User endpoints
  • Post endpoints

Predefined users and posts by seeder

user/admin/superadmin
 {
            _id:"65f08bf319ed20287fd19c3a",
            name: "super_admin",
            email: "super_admin@super_admin.com",
            password: await bcrypt.hash("123456" , 8 ),
            role: "super_admin"

        },
        {
            _id: "65f08bf319ed20287fd19c3b",
            name: "admin",
            email: "[email protected]",
            password: await bcrypt.hash("123456" , 8 ),
            role: "admin"

        },
        {
            _id:"65f08bf319ed20287fd19c3c",
            name: "user",
            email: "[email protected]",
            password: await bcrypt.hash("123456" , 8 ),
            role: "user"

        }

posts

 {
                _id: "65f08bf319ed20287fd19c56",
                title: "el tituloooo",
                text: "Conscendo addo venia ubi ciminatio utpote uredo auctor cursus. Cometes…",
                nick: "65f08bf319ed20287fd19c3c"
    
            },
            {
                _id: "65f08bf319ed20287fd19c55",
                title: "el tituloooo2",
                text: "Conscendo addo venia ubi ciminatio utpote uredo auctor cursus. Cometes…",
                nick: "65f08bf319ed20287fd19c3c"
                
    
            },
            {
                _id: "65f08bf319ed20287fd19c54",
                title: "el tituloooo3",
                text: "Conscendo addo venia ubi ciminatio utpote uredo auctor cursus. Cometes…",
                nick: "65f08bf319ed20287fd19c3c"
               
    
            }
Make a register

POST https://hi-its-me-dev-sjmz.2.sg-1.fl0.io/api/auth/register

- Make a register of one user ( default role is "user")
{
  "email": "[email protected]",
  "password":"123456"
}

Login of a user

POST https://hi-its-me-dev-sjmz.2.sg-1.fl0.io/api/auth/login

- Logged User have a token
{
  "email":"[email protected]",
  "password":"123456"
}

Retrieve all users

GET https://hi-its-me-dev-sjmz.2.sg-1.fl0.io/api/users/

- Only for who had "super-admin" role. - Add the user token on auth/ bearer. - Retrieve all users.

Retrieve user profile

GET https://hi-its-me-dev-sjmz.2.sg-1.fl0.io/api/users/profile

- For all are logged users. - This works for all users only for see their own profile. - Add this user's token in auth/bearer too.
//write this on body

{
  "email": "[email protected]",
  "password":"123456"
}
Delete a post

DELETE https://hi-its-me-dev-sjmz.2.sg-1.fl0.io/api/posts/:id

  • Delete a post by id.
  • It is only allowed for the owner of the post.
  • Add User's token on Auth/Bearer.
Update a post

PUT https://hi-its-me-dev-sjmz.2.sg-1.fl0.io/api/posts/:id

- Update the title of a post by id. - It is only allowed for the owner of the post. - Add User's token on Auth/Bearer.
//write this on body
{
  "title": "feliz navidad"
}

Get all your own posts

GET https://hi-its-me-dev-sjmz.2.sg-1.fl0.io/api/posts/own

  • Add User's token on Auth/Bearer.

Get all posts view feed

GET https://hi-its-me-dev-sjmz.2.sg-1.fl0.io/api/posts

  • Add a token in Auth/Bearer because the watcher should be logged.

Get post by Id

GET https://hi-its-me-dev-sjmz.2.sg-1.fl0.io/api/posts/:id

  • Add a token in Auth/Bearer because the watcher should be logged.
  • Add postId in the request to find it.

Do Like and Unlike a post by Id

PUT https://hi-its-me-dev-sjmz.2.sg-1.fl0.io/api/posts/like/:id

- Add a token in Auth/Bearer because the watcher should be logged.

bug This only worked if you write true on body because the "botton: like" should be "pressedON" to allow the likes acount change true/false and show whose liked the post. SOLVED deleting like param.

To add / Bugs

  • I tried to add "name" parameter in body of users. But this hasnt control if name is different because in model is not required..
  • Added 3 posts and 3 users default for some functionalities.

Agreements

Thanks all for helping and support my progress in this proyect.

Marta GitHub

Ana GitHub

Pedro GitHub

Fernando GitHub

Carlos GitHub

Fran GitHub

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published