Skip to content

A social network API based on twitter built with expressjs.

License

Notifications You must be signed in to change notification settings

leonfoliveira/Social-Backend

Repository files navigation

Social Backend

MIT Licence David DM Travis CI Heroku

A social network API based on twitter under development using solid design and clean arquitecture principles.

Disclaimer

❗ Developed just for academic reasons by a junior developer with little experience, feel free to correct any mistakes I make, I'll be glad to learn from you.

Scripts

dev: Start server in development mode

start: Start server in production mode

test: Run test suits with jest

build: Compile typescript files to plain javascript files into "dist" folder

migrate: Migrate the database specified by environment variables

Endpoints

🔒: Requires authentication


GET   •   /api/sessions 🔒   •   Get data from the user authenticated

Request

"header": {
    "authorization": "<string required> [Bearer JWT token]"
},

Response

Code : 200 OK

"body": {
    "id": "<string> [User id]",
    "email": "<string> [User email]",
    "name": "<string> [User name]",
    "tag": "<string> [User tag]",
    "description": "<string> [User description]",
    "image": "<string> [User image url]",
    "followers": "<number> [User followers count]",
    "following": "<number> [User following count]",
    "createdAt": "<Date> [User date/time of creation]",
    "updatedAt": "<Date> [User date/time of last update]"
}
POST   •   /api/sessions   •   Create a new session with user data provided (signin)

Request

"body": {
    "email": "<string email max=50 required> [User email]",
    "password": "<string min=8 max=30 required> [User password]"
}

Response

Code : 201 CREATED

"body": {
    "token": "<string> [JWT token]",
    "user": {
        "id": "<string> [User id]",
        "email": "<string> [User email]",
        "name": "<string> [User name]",
        "tag": "<string> [User tag]",
        "description": "<string> [User description]",
        "image": "<string> [User image url]",
        "followers": "<number> [User followers count]",
        "following": "<number> [User following count]",
        "createdAt": "<Date> [User date/time of creation]",
        "updatedAt": "<Date> [User date/time of last update]"
    }
}
DELETE   •   /api/sessions 🔒   •   Revoke the authorization token

Request

"header": {
    "authorization": "<string required> [Bearer JWT token]"
},

Response

Code : 200 OK


GET   •   /api/users   •   Get a list of all users

Request

"query": {
    "page": "<number integer positive optional default=1> [Page]",
    "per-page": "<number integer positive max=30 optional default=10> [Users per page]",
    "slug": "<string optional> [Search term to filter by name or by tag, (starts with \"@\" to filter only by tag)]"
}

Response

Code : 200 OK

"header": {
    "x-total-count": "<number> [Total of users]",
    "x-total-pages": "<number> [Total of pages]"
}

"body": [
    {
        "id": "<string> [User id]",
        "name": "<string> [User name]",
        "tag": "<string> [User tag]",
        "description": "<string> [User description]",
        "image": "<string> [User image url]",
        "followers": "<number> [User followers count]",
        "following": "<number> [User following count]",
        "createdAt": "<Date> [User date/time of creation]",
        "updatedAt": "<Date> [User date/time of last update]"
    }
]
GET   •   /api/users/:id   •   Get data from a specific user searching for its id

Request

"params": {
    "id": "<string required> [User id]"
}

Response

Code : 200 OK

"body": {
    "id": "<string> [User id]",
    "name": "<string> [User name]",
    "tag": "<string> [User tag]",
    "description": "<string> [User description]",
    "image": "<string> [User image url]",
    "followers": "<number> [User followers count]",
    "following": "<number> [User following count]",
    "createdAt": "<Date> [User date/time of creation]",
    "updatedAt": "<Date> [User date/time of last update]"
}
POST   •   /api/users   •   Create a new user with the data provided

Request

"body": {
    "email": "<string email max=50 required> [User email]",
    "name": "<string max=50 required> [User name]",
    "tag": "<string alphanum max=30 required> [User tag]",
    "password": "<string min=8 max=30 required> [User password]",
    "image": "<image/(png|jpg|jpeg) max=1mb optional> [User picture]"
}

Response

Code : 201 CREATED

"body": {
    "id": "<string> [User id]",
    "email": "<string> [User email]",
    "name": "<string> [User name]",
    "tag": "<string> [User tag]",
    "description": "<string> [User description]",
    "image": "<string> [User image url]",
    "followers": "<number> [User followers count]",
    "following": "<number> [User following count]",
    "createdAt": "<Date> [User date/time of creation]",
    "updatedAt": "<Date> [User date/time of last update]"
}
PUT   •   /api/users 🔒   •   Update the authorized user

Request

"header": {
    "authorization": "<string bearer token required> [Bearer JWT token]"
},

"body": {
    "email": "<string email max=50 required> [User email]",
    "password": "<string min=8 max=30 required> [User password]",
    "image": "<image/(png|jpg|jpeg) max=1mb optional> [User picture]"
}

Response

Code : 200 OK

"body": {
    "id": "<string> [User id]",
    "email": "<string> [User email]",
    "name": "<string> [User name]",
    "tag": "<string> [User tag]",
    "description": "<string> [User description]",
    "image": "<string> [User image url]",
    "followers": "<number> [User followers count]",
    "following": "<number> [User following count]",
    "createdAt": "<Date> [User date/time of creation]",
    "updatedAt": "<Date> [User date/time of last update]"
}
DELETE   •   /api/users 🔒   •   Delete the authorized user

Request

"header": {
    "authorization": "<string bearer token required> [Bearer JWT token]"
},

Response

Code : 200 OK

GET   •   /api/users/trend   •   Get a list of all users ordered by last followers count

Request

"query": {
    "page": "<number integer positive optional default=1> [Page]",
    "per-page": "<number integer positive max=30 optional default=10> [Users per page]",
    "time": "<number integer positive optional max=31536000000(1 year) default=86400000(1 day)> [Time before now to count last followers]"
}

Response

Code : 200 OK

"header": {
    "x-total-count": "<number> [Total of users]",
    "x-total-pages": "<number> [Total of pages]"
}

"body": [
    {
        "id": "<string> [User id]",
        "name": "<string> [User name]",
        "tag": "<string> [User tag]",
        "description": "<string> [User description]",
        "image": "<string> [User image url]",
        "followers": "<number> [User followers count]",
        "following": "<number> [User following count]",
        "createdAt": "<Date> [User date/time of creation]",
        "updatedAt": "<Date> [User date/time of last update]"
    }
]

GET   •   /api/follows   •   Get list of all follows

Request

"query": {
    "page": "<number integer positive optional default=1> [Page]",
    "per-page": "<number integer positive max=30 optional default=10> [Follows per page]",
    "follower-id": "<string optional> [User follower id]",
    "target-id": "<string optional> [User target id]"
},

Response

Code : 200 OK

"body": [
    {
        "id": "<string> [Follow id]",
        "follower": {
            "id": "<string> [User follower id]",
            "name": "<string> [User follower name]",
            "tag": "<string> [User follower tag]",
            "description": "<string> [User follower description]",
            "image": "<string> [User follower image url]",
            "createdAt": "<Date> [User follower date/time of creation]",
            "updatedAt": "<Date> [User follower date/time of last update]"
        },
        "target": {
            "id": "<string> [User target id]",
            "name": "<string> [User target name]",
            "tag": "<string> [User target tag]",
            "description": "<string> [User target description]",
            "image": "<string> [User target image url]",
            "createdAt": "<Date> [User target date/time of creation]",
            "updatedAt": "<Date> [User target date/time of last update]"
        },
        "createdAt": "<Date> [Follow date/time of creation]",
    }
]
GET   •   /api/follows/:followerId/:targetId   •   Get data from a specific follow

Request

"params": {
    "followerId": "<string required> [User follower id]",
    "targetId": "<string required> [User target id]"
},

Response

Code : 200 OK

"body": {
    "id": "<string> [Follow id]",
    "follower": {
        "id": "<string> [User follower id]",
        "name": "<string> [User follower name]",
        "tag": "<string> [User follower tag]",
        "description": "<string> [User follower description]",
        "image": "<string> [User follower image url]",
        "createdAt": "<Date> [User follower date/time of creation]",
        "updatedAt": "<Date> [User follower date/time of last update]"
    },
    "target": {
        "id": "<string> [User target id]",
        "name": "<string> [User target name]",
        "tag": "<string> [User target tag]",
        "description": "<string> [User target description]",
        "image": "<string> [User target image url]",
        "createdAt": "<Date> [User target date/time of creation]",
        "updatedAt": "<Date> [User target date/time of last update]"
    },
    "createdAt": "<Date> [Follow date/time of creation]",
}
POST   •   /api/follows 🔒   •   Create a new follow between the user authenticated and a target provided

Request

"header": {
    "authorization": "<string bearer token required> [Bearer JWT token]"
},

"body": {
    "targetId": "<string required> [User target id]",
}

Response

Code : 201 CREATED

"body": {
    "id": "<string> [Follow id]",
    "follower": {
        "id": "<string> [User follower id]",
        "name": "<string> [User follower name]",
        "tag": "<string> [User follower tag]",
        "description": "<string> [User follower description]",
        "image": "<string> [User follower image url]",
        "createdAt": "<Date> [User follower date/time of creation]",
        "updatedAt": "<Date> [User follower date/time of last update]"
    },
    "target": {
        "id": "<string> [User target id]",
        "name": "<string> [User target name]",
        "tag": "<string> [User target tag]",
        "description": "<string> [User target description]",
        "image": "<string> [User target image url]",
        "createdAt": "<Date> [User target date/time of creation]",
        "updatedAt": "<Date> [User target date/time of last update]"
    },
    "createdAt": "<Date> [Follow date/time of creation]",
}
DELETE   •   /api/follows/:id 🔒   •   Delete a follow searching for its id

Request

"header": {
    "authorization": "<string bearer token required> [Bearer JWT token]"
},

"params": {
    "id": "<string required> [Follow id]",
}

Response

Code : 201 CREATED


GET   •   /api/posts   •   Get a list of all posts

Request

"query": {
    "page": "<number integer positive optional default=1> [Page]",
    "per-page": "<number integer positive optional max=30 default=10> [Posts per page]",
    "author-id": "<string optional> [User author id]",
    "slug": "<string optional> [Search term to filter by text]"
},

Response

Code : 200 OK

"body": [
    {
        "id": "<string> [Post id]",
        "text": "<string> [Post text]",
        "image": "<string> [Post image]",
        "likes": "<number> [Post likes count]",
        "author": {
            "id": "<string> [User author id]",
            "name": "<string> [User author name]",
            "tag": "<string> [User author tag]",
            "description": "<string> [User author description]",
            "image": "<string> [User author image url]",
            "createdAt": "<Date> [User author date/time of creation]",
            "updatedAt": "<Date> [User author date/time of last update]"
        },
        "createdAt": "<Date> [Post date/time of creation]",
        "updatedAt": "<Date> [Post date/time of last update]"
    }
]
GET   •   /api/posts/:id   •   Get data from a specific post searching for it's id

Request

"params": {
    "id": "<string required> [Post id]"
},

Response

Code : 200 OK

"body": {
    "id": "<string> [Post id]",
    "text": "<string> [Post text]",
    "image": "<string> [Post image]",
    "likes": "<number> [Post likes count]",
    "author": {
        "id": "<string> [User author id]",
        "name": "<string> [User author name]",
        "tag": "<string> [User author tag]",
        "description": "<string> [User author description]",
        "image": "<string> [User author image url]",
        "createdAt": "<Date> [User author date/time of creation]",
        "updatedAt": "<Date> [User author date/time of last update]"
    },
    "createdAt": "<Date> [Post date/time of creation]",
    "updatedAt": "<Date> [Post date/time of last update]"
}
POST   •   /api/posts 🔒   •   Create a new post with the data provided and author from authentication

Request

"header": {
    "authorization": "<string bearer token required> [Bearer JWT token]"
},

"body": {
    "text": "<string max=256 optional> [Post text]",
    "image": "<image/(png|jpg|jpeg) max=1mb optional> [Post image]",
}

Response

Code : 201 CREATED

"body": {
    "id": "<string> [Post id]",
    "text": "<string> [Post text]",
    "image": "<string> [Post image]",
    "likes": "<number> [Post likes count]",
    "author": {
        "id": "<string> [User author id]",
        "email": "<string> [User email]",
        "name": "<string> [User author name]",
        "tag": "<string> [User author tag]",
        "description": "<string> [User author description]",
        "image": "<string> [User author image url]",
        "createdAt": "<Date> [User author date/time of creation]",
        "updatedAt": "<Date> [User author date/time of last update]"
    },
    "createdAt": "<Date> [Post date/time of creation]",
    "updatedAt": "<Date> [Post date/time of last update]"
}
PUT   •   /api/posts/:id 🔒   •   Update a post with the data provided

Request

"header": {
    "authorization": "<string bearer token required> [Bearer JWT token]"
},

"params": {
    "id": "<string required> [Post id]"
}

"body": {
    "text": "<string max=256 required> [Post text]",
}

Response

Code : 201 CREATED

"body": {
    "id": "<string> [Post id]",
    "text": "<string> [Post text]",
    "image": "<string> [Post image]",
    "likes": "<number> [Post likes count]",
    "author": {
        "id": "<string> [User author id]",
        "email": "<string> [User email]",
        "name": "<string> [User author name]",
        "tag": "<string> [User author tag]",
        "description": "<string> [User author description]",
        "image": "<string> [User author image url]",
        "createdAt": "<Date> [User author date/time of creation]",
        "updatedAt": "<Date> [User author date/time of last update]"
    },
    "createdAt": "<Date> [Post date/time of creation]",
    "updatedAt": "<Date> [Post date/time of last update]"
}
DELETE   •   /api/posts/:id 🔒   •   Delete a post searching for its id

Request

"header": {
    "authorization": "<string bearer token required> [Bearer JWT token]"
},

"params": {
    "id": "<string required> [Post id]"
},

"header": {
    "authorization": "<string bearer token required> [Bearer JWT token]"
},

Response

Code : 200 OK

GET   •   /api/posts/feed 🔒   •   Get a list of last posts from following users and the authenticated user

Request

"header": {
    "authorization": "<string bearer token required> [Bearer JWT token]"
},

"query": {
    "page": "<number integer positive optional default=1> [Page]",
    "per-page": "<number integer positive optional max=30 default=10> [Posts per page]"
},

Response

Code : 200 OK

"body": [
    {
        "id": "<string> [Post id]",
        "text": "<string> [Post text]",
        "image": "<string> [Post image]",
        "likes": "<number> [Post likes count]",
        "author": {
            "id": "<string> [User author id]",
            "name": "<string> [User author name]",
            "tag": "<string> [User author tag]",
            "description": "<string> [User author description]",
            "image": "<string> [User author image url]",
            "createdAt": "<Date> [User author date/time of creation]",
            "updatedAt": "<Date> [User author date/time of last update]"
        },
        "createdAt": "<Date> [Post date/time of creation]",
        "updatedAt": "<Date> [Post date/time of last update]"
    }
]
GET   •   /api/posts/trend   •   Get a list of posts ordered by last likes count

Request

"query": {
    "page": "<number integer positive optional default=1> [Page]",
    "per-page": "<number integer positive optional max=30 default=10> [Posts per page]",
    "time": "<number integer positive optional max=31536000000(1 year) default=86400000(1 day)> [Time before now to count last likes]"
},

Response

Code : 200 OK

"body": [
    {
        "id": "<string> [Post id]",
        "text": "<string> [Post text]",
        "image": "<string> [Post image]",
        "likes": "<number> [Post likes count]",
        "author": {
            "id": "<string> [User author id]",
            "name": "<string> [User author name]",
            "tag": "<string> [User author tag]",
            "description": "<string> [User author description]",
            "image": "<string> [User author image url]",
            "createdAt": "<Date> [User author date/time of creation]",
            "updatedAt": "<Date> [User author date/time of last update]"
        },
        "createdAt": "<Date> [Post date/time of creation]",
        "updatedAt": "<Date> [Post date/time of last update]"
    }
]

GET   •   /api/post-likes   •   Get list of all post-likes

Request

"query": {
    "page": "<number integer positive optional default=1> [Page]",
    "per-page": "<number integer positive max=30 optional default=10> [Follows per page]",
    "user-id": "<string optional> [User id]",
    "post-id": "<string optional> [Post id]"
},

Response

Code : 200 OK

"body": [
    {
        "id": "<string> [Post-Like id]",
        "user": {
            "id": "<string> [User id]",
            "name": "<string> [User name]",
            "tag": "<string> [User tag]",
            "description": "<string> [User description]",
            "image": "<string> [User image url]",
            "createdAt": "<Date> [User date/time of creation]",
            "updatedAt": "<Date> [User date/time of last update]"
        },
        "post": {
            "id": "<string> [Post id]",
            "text": "<string> [Post text]",
            "image": "<string> [Post image]",
            "author": {
                "id": "<string> [User author id]",
                "name": "<string> [User author name]",
                "tag": "<string> [User author tag]",
                "description": "<string> [User author description]",
                "image": "<string> [User author image url]",
                "createdAt": "<Date> [User author date/time of creation]",
                "updatedAt": "<Date> [User author date/time of last update]"
            },
            "createdAt": "<Date> [Post date/time of creation]",
            "updatedAt": "<Date> [Post date/time of last update]"
        },
        "createdAt": "<Date> [Post-Like date/time of creation]",
    }
]
GET   •   /api/post-likes/:userId/:postId   •   Get data from a specific post-like

Request

"params": {
    "userId": "<string required> [User id]",
    "postId": "<string required> [Post id]"
},

Response

Code : 200 OK

"body": {
    "id": "<string> [Post-Like id]",
    "user": {
        "id": "<string> [User id]",
        "name": "<string> [User name]",
        "tag": "<string> [User tag]",
        "description": "<string> [User description]",
        "image": "<string> [User image url]",
        "createdAt": "<Date> [User date/time of creation]",
        "updatedAt": "<Date> [User date/time of last update]"
    },
    "post": {
        "id": "<string> [Post id]",
        "text": "<string> [Post text]",
        "image": "<string> [Post image]",
        "author": {
            "id": "<string> [User author id]",
            "name": "<string> [User author name]",
            "tag": "<string> [User author tag]",
            "description": "<string> [User author description]",
            "image": "<string> [User author image url]",
            "createdAt": "<Date> [User author date/time of creation]",
            "updatedAt": "<Date> [User author date/time of last update]"
        },
        "createdAt": "<Date> [Post date/time of creation]",
        "updatedAt": "<Date> [Post date/time of last update]"
    },
    "createdAt": "<Date> [Post-Like date/time of creation]",
}
POST   •   /api/post-likes 🔒   •   Create a new post-like from the user authenticated to a post provided

Request

"header": {
    "authorization": "<string bearer token required> [Bearer JWT token]"
},

"body": {
    "postId": "<string required> [Post id]",
}

Response

Code : 201 CREATED

"body": {
    "id": "<string> [Post-Like id]",
    "user": {
        "id": "<string> [User id]",
        "name": "<string> [User name]",
        "tag": "<string> [User tag]",
        "description": "<string> [User description]",
        "image": "<string> [User image url]",
        "createdAt": "<Date> [User date/time of creation]",
        "updatedAt": "<Date> [User date/time of last update]"
    },
    "post": {
        "id": "<string> [Post id]",
        "text": "<string> [Post text]",
        "image": "<string> [Post image]",
        "author": {
            "id": "<string> [User author id]",
            "name": "<string> [User author name]",
            "tag": "<string> [User author tag]",
            "description": "<string> [User author description]",
            "image": "<string> [User author image url]",
            "createdAt": "<Date> [User author date/time of creation]",
            "updatedAt": "<Date> [User author date/time of last update]"
        },
        "createdAt": "<Date> [Post date/time of creation]",
        "updatedAt": "<Date> [Post date/time of last update]"
    },
    "createdAt": "<Date> [Post-Like date/time of creation]",
}
DELETE   •   /api/post-likes/:id 🔒   •   Delete a post-like searching for its id

Request

"header": {
    "authorization": "<string bearer token required> [Bearer JWT token]"
},

"params": {
    "id": "<string required> [Post-Like id]",
}

Response

Code : 201 CREATED


GET   •   /api/comments   •   Get a list of all comments

Request

"query": {
    "page": "<number integer positive optional default=1> [Page]",
    "per-page": "<number integer positive optional max=30 default=10> [Posts per page]",
    "user-id": "<string optional> [User id]",
    "post-id": "<string optional> [Post id]",
    "slug": "<string optional> [Search term to filter by text]"
},

Response

Code : 200 OK

"body": [
    {
        "id": "<string> [Comment id]",
        "text": "<string> [Comment text]",
        "likes": "<number> [Comment likes count]",
        "user": {
            "id": "<string> [User id]",
            "name": "<string> [User name]",
            "tag": "<string> [User tag]",
            "description": "<string> [User description]",
            "image": "<string> [User image url]",
            "createdAt": "<Date> [User date/time of creation]",
            "updatedAt": "<Date> [User date/time of last update]"
        },
        "post": {
            "id": "<string> [Post id]",
            "text": "<string> [Post text]",
            "image": "<string> [Post image]",
            "author": {
                "id": "<string> [User author id]",
                "name": "<string> [User author name]",
                "tag": "<string> [User author tag]",
                "description": "<string> [User author description]",
                "image": "<string> [User author image url]",
                "createdAt": "<Date> [User author date/time of creation]",
                "updatedAt": "<Date> [User author date/time of last update]"
            },
            "createdAt": "<Date> [Post date/time of creation]",
            "updatedAt": "<Date> [Post date/time of last update]"
        },
        "createdAt": "<Date> [Comment date/time of creation]",
        "updatedAt": "<Date> [Comment date/time of last update]"
    }
]
GET   •   /api/comments/:id   •   Get data from a specific comment searching for it's id

Request

"params": {
    "id": "<string required> [Comment id]"
},

Response

Code : 200 OK

"body": {
    "id": "<string> [Comment id]",
    "text": "<string> [Comment text]",
    "likes": "<number> [Comment likes count]",
    "user": {
        "id": "<string> [User id]",
        "name": "<string> [User name]",
        "tag": "<string> [User tag]",
        "description": "<string> [User description]",
        "image": "<string> [User image url]",
        "createdAt": "<Date> [User date/time of creation]",
        "updatedAt": "<Date> [User date/time of last update]"
    },
    "post": {
        "id": "<string> [Post id]",
        "text": "<string> [Post text]",
        "image": "<string> [Post image]",
        "author": {
            "id": "<string> [User author id]",
            "name": "<string> [User author name]",
            "tag": "<string> [User author tag]",
            "description": "<string> [User author description]",
            "image": "<string> [User author image url]",
            "createdAt": "<Date> [User author date/time of creation]",
            "updatedAt": "<Date> [User author date/time of last update]"
        },
        "createdAt": "<Date> [Post date/time of creation]",
        "updatedAt": "<Date> [Post date/time of last update]"
    },
    "createdAt": "<Date> [Comment date/time of creation]",
    "updatedAt": "<Date> [Comment date/time of last update]"
}
POST   •   /api/comments 🔒   •   Create a new comment with the data provided and user from authentication

Request

"header": {
    "authorization": "<string bearer token required> [Bearer JWT token]"
},

"body": {
    "text": "<string max=256 optional> [Comment text]",
}

Response

Code : 201 CREATED

"body": {
    "id": "<string> [Comment id]",
    "text": "<string> [Comment text]",
    "likes": "<number> [Comment likes count]",
    "user": {
        "id": "<string> [User id]",
        "name": "<string> [User name]",
        "tag": "<string> [User tag]",
        "description": "<string> [User description]",
        "image": "<string> [User image url]",
        "createdAt": "<Date> [User date/time of creation]",
        "updatedAt": "<Date> [User date/time of last update]"
    },
    "post": {
        "id": "<string> [Post id]",
        "text": "<string> [Post text]",
        "image": "<string> [Post image]",
        "author": {
            "id": "<string> [User author id]",
            "name": "<string> [User author name]",
            "tag": "<string> [User author tag]",
            "description": "<string> [User author description]",
            "image": "<string> [User author image url]",
            "createdAt": "<Date> [User author date/time of creation]",
            "updatedAt": "<Date> [User author date/time of last update]"
        },
        "createdAt": "<Date> [Post date/time of creation]",
        "updatedAt": "<Date> [Post date/time of last update]"
    },
    "createdAt": "<Date> [Comment date/time of creation]",
    "updatedAt": "<Date> [Comment date/time of last update]"
}
PUT   •   /api/comments/:id 🔒   •   Update a comment with the data provided

Request

"header": {
    "authorization": "<string bearer token required> [Bearer JWT token]"
},

"params": {
    "id": "<string required> [Comment id]"
}

"body": {
    "text": "<string max=256 required> [Comment text]",
}

Response

Code : 201 CREATED

"body": {
    "id": "<string> [Comment id]",
    "text": "<string> [Comment text]",
    "likes": "<number> [Comment likes count]",
    "user": {
        "id": "<string> [User id]",
        "name": "<string> [User name]",
        "tag": "<string> [User tag]",
        "description": "<string> [User description]",
        "image": "<string> [User image url]",
        "createdAt": "<Date> [User date/time of creation]",
        "updatedAt": "<Date> [User date/time of last update]"
    },
    "post": {
        "id": "<string> [Post id]",
        "text": "<string> [Post text]",
        "image": "<string> [Post image]",
        "author": {
            "id": "<string> [User author id]",
            "name": "<string> [User author name]",
            "tag": "<string> [User author tag]",
            "description": "<string> [User author description]",
            "image": "<string> [User author image url]",
            "createdAt": "<Date> [User author date/time of creation]",
            "updatedAt": "<Date> [User author date/time of last update]"
        },
        "createdAt": "<Date> [Post date/time of creation]",
        "updatedAt": "<Date> [Post date/time of last update]"
    },
    "createdAt": "<Date> [Comment date/time of creation]",
    "updatedAt": "<Date> [Comment date/time of last update]"
}
DELETE   •   /api/comments/:id 🔒   •   Delete a comment searching for its id

Request

"header": {
    "authorization": "<string bearer token required> [Bearer JWT token]"
},

"params": {
    "id": "<string required> [Comment id]"
},

"header": {
    "authorization": "<string bearer token required> [Bearer JWT token]"
},

Response

Code : 200 OK


GET   •   /api/comment-likes   •   Get list of all comment-likes

Request

"query": {
    "page": "<number integer positive optional default=1> [Page]",
    "per-page": "<number integer positive max=30 optional default=10> [Follows per page]",
    "user-id": "<string optional> [User id]",
    "comment-id": "<string optional> [Comment id]"
},

Response

Code : 200 OK

"body": [
    {
        "id": "<string> [Comment-Like id]",
        "user": {
            "id": "<string> [User id]",
            "name": "<string> [User name]",
            "tag": "<string> [User tag]",
            "description": "<string> [User description]",
            "image": "<string> [User image url]",
            "createdAt": "<Date> [User date/time of creation]",
            "updatedAt": "<Date> [User date/time of last update]"
        },
        "comment": {
            "id": "<string> [Comment id]",
            "text": "<string> [Comment text]",
            "user": {
                "id": "<string> [User id]",
                "name": "<string> [User name]",
                "tag": "<string> [User tag]",
                "description": "<string> [User description]",
                "image": "<string> [User image url]",
                "createdAt": "<Date> [User date/time of creation]",
                "updatedAt": "<Date> [User date/time of last update]"
            },
            "post": {
                "id": "<string> [Post id]",
                "text": "<string> [Post text]",
                "image": "<string> [Post image]",
                "author": {
                    "id": "<string> [User author id]",
                    "name": "<string> [User author name]",
                    "tag": "<string> [User author tag]",
                    "description": "<string> [User author description]",
                    "image": "<string> [User author image url]",
                    "createdAt": "<Date> [User author date/time of creation]",
                    "updatedAt": "<Date> [User author date/time of last update]"
                },
                "createdAt": "<Date> [Post date/time of creation]",
                "updatedAt": "<Date> [Post date/time of last update]"
            },
            "createdAt": "<Date> [Comment date/time of creation]",
            "updatedAt": "<Date> [Comment date/time of last update]"
        },
        "createdAt": "<Date> [Comment-Like date/time of creation]"
    }
]
GET   •   /api/comment-likes/:userId/:commentId   •   Get data from a specific comment-like

Request

"params": {
    "userId": "<string required> [User id]",
    "commentId": "<string required> [Comment id]"
},

Response

Code : 200 OK

"body": {
    "id": "<string> [Comment-Like id]",
    "user": {
        "id": "<string> [User id]",
        "name": "<string> [User name]",
        "tag": "<string> [User tag]",
        "description": "<string> [User description]",
        "image": "<string> [User image url]",
        "createdAt": "<Date> [User date/time of creation]",
        "updatedAt": "<Date> [User date/time of last update]"
    },
    "comment": {
        "id": "<string> [Comment id]",
        "text": "<string> [Comment text]",
        "user": {
            "id": "<string> [User id]",
            "name": "<string> [User name]",
            "tag": "<string> [User tag]",
            "description": "<string> [User description]",
            "image": "<string> [User image url]",
            "createdAt": "<Date> [User date/time of creation]",
            "updatedAt": "<Date> [User date/time of last update]"
        },
        "post": {
            "id": "<string> [Post id]",
            "text": "<string> [Post text]",
            "image": "<string> [Post image]",
            "author": {
                "id": "<string> [User author id]",
                "name": "<string> [User author name]",
                "tag": "<string> [User author tag]",
                "description": "<string> [User author description]",
                "image": "<string> [User author image url]",
                "createdAt": "<Date> [User author date/time of creation]",
                "updatedAt": "<Date> [User author date/time of last update]"
            },
            "createdAt": "<Date> [Post date/time of creation]",
            "updatedAt": "<Date> [Post date/time of last update]"
        },
        "createdAt": "<Date> [Comment date/time of creation]",
        "updatedAt": "<Date> [Comment date/time of last update]"
    },
    "createdAt": "<Date> [Comment-Like date/time of creation]"
}
POST   •   /api/comment-likes 🔒   •   Create a new comment-like from the user authenticated to a comment provided

Request

"header": {
    "authorization": "<string bearer token required> [Bearer JWT token]"
},

"body": {
    "commentId": "<string required> [Comment id]",
}

Response

Code : 201 CREATED

"body": {
    "id": "<string> [Comment-Like id]",
    "user": {
        "id": "<string> [User id]",
        "name": "<string> [User name]",
        "tag": "<string> [User tag]",
        "description": "<string> [User description]",
        "image": "<string> [User image url]",
        "createdAt": "<Date> [User date/time of creation]",
        "updatedAt": "<Date> [User date/time of last update]"
    },
    "comment": {
        "id": "<string> [Comment id]",
        "text": "<string> [Comment text]",
        "user": {
            "id": "<string> [User id]",
            "name": "<string> [User name]",
            "tag": "<string> [User tag]",
            "description": "<string> [User description]",
            "image": "<string> [User image url]",
            "createdAt": "<Date> [User date/time of creation]",
            "updatedAt": "<Date> [User date/time of last update]"
        },
        "post": {
            "id": "<string> [Post id]",
            "text": "<string> [Post text]",
            "image": "<string> [Post image]",
            "author": {
                "id": "<string> [User author id]",
                "name": "<string> [User author name]",
                "tag": "<string> [User author tag]",
                "description": "<string> [User author description]",
                "image": "<string> [User author image url]",
                "createdAt": "<Date> [User author date/time of creation]",
                "updatedAt": "<Date> [User author date/time of last update]"
            },
            "createdAt": "<Date> [Post date/time of creation]",
            "updatedAt": "<Date> [Post date/time of last update]"
        },
        "createdAt": "<Date> [Comment date/time of creation]",
        "updatedAt": "<Date> [Comment date/time of last update]"
    },
    "createdAt": "<Date> [Comment-Like date/time of creation]"
}
DELETE   •   /api/comment-likes/:id 🔒   •   Delete a comment-like searching for its id

Request

"header": {
    "authorization": "<string bearer token required> [Bearer JWT token]"
},

"params": {
    "id": "<string required> [Comment-Like id]",
}

Response

Code : 201 CREATED

Releases

No releases published

Packages

No packages published

Languages