Skip to content
This repository was archived by the owner on Apr 14, 2024. It is now read-only.

Latest commit

History

30 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

DREAMTALK API

Simple twitter-like backend API.

DEPENDENCIES

build with:

  • TypeScript
  • TypeORM
  • Express
  • pg
  • JWT
  • bcryptjs
  • Joi

(complete list)

and is using PostgreSQL as database.

ENTITIES

DreamtalkAPI is working with 4 basic entities:

  • Dreamer (User)
  • Dreams (Posts)
  • Comments (on Posts)
  • Replies (to comments)

EXAMPLE JSON OBJECTS (PUBLIC)

Dreamer

{
"id": "63daa685-0791-4370-8bea-fa8d1cfad4b3",
"dateJoined": "2021-05-17T19:17:13.242Z",
"username": "oskar",
"nickname": "oskar"
}

Dream

{
"id": "60d660df-2edb-4985-bcce-09fc12b7a633",
"dateCreated": "2021-05-22T22:28:44.604Z",
"dateEdited": "2021-05-22T22:28:44.604Z",
"title": "example dream",
"content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam egestas arcu gravida dui imperdiet egestas. Mauris euismod sollicitudin turpis, sit.",
"author": {
"id": "c34b180b-16ff-4274-ab85-e8d32b28e712",
"dateJoined": "2021-05-22T22:26:36.181Z",
"username": "devskar",
"nickname": "devskar"
}
}

Comment

{
"message": "Successfully added comment.",
"comment": {
"content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam egestas arcu gravida dui imperdiet egestas. Mauris euismod sollicitudin turpis, sit.",
"author": {
"id": "c34b180b-16ff-4274-ab85-e8d32b28e712",
"dateJoined": "2021-05-22T22:26:36.181Z",
"username": "devskar",
"nickname": "devskar"
},
"dream": {
"id": "60d660df-2edb-4985-bcce-09fc12b7a633",
"dateCreated": "2021-05-22T22:28:44.604Z",
"dateEdited": "2021-05-22T22:28:44.604Z",
"title": "example dream",
"content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam egestas arcu gravida dui imperdiet egestas. Mauris euismod sollicitudin turpis, sit."
},
"id": "4a1f4231-810f-4e20-9432-63d89164bf5d",
"dateCreated": "2021-05-22T22:29:56.066Z",
"dateEdited": "2021-05-22T22:29:56.066Z"
}
}

Replies

{
"id": "a8d533db-fd61-4f94-957a-814af38901a1",
"dateCreated": "2021-05-22T22:36:22.186Z",
"dateEdited": "2021-05-22T22:36:22.186Z",
"content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam egestas arcu gravida dui imperdiet egestas. Mauris euismod sollicitudin turpis, sit.",
"author": {
"id": "c34b180b-16ff-4274-ab85-e8d32b28e712",
"dateJoined": "2021-05-22T22:26:36.181Z",
"username": "devskar",
"nickname": "devskar"
},
"parent": {
"id": "4a1f4231-810f-4e20-9432-63d89164bf5d",
"dateCreated": "2021-05-22T22:29:56.066Z",
"dateEdited": "2021-05-22T22:29:56.066Z",
"content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam egestas arcu gravida dui imperdiet egestas. Mauris euismod sollicitudin turpis, sit.",
"dream": {
"id": "60d660df-2edb-4985-bcce-09fc12b7a633",
"dateCreated": "2021-05-22T22:28:44.604Z",
"dateEdited": "2021-05-22T22:28:44.604Z",
"title": "example dream",
"content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam egestas arcu gravida dui imperdiet egestas. Mauris euismod sollicitudin turpis, sit."
}
}
}

API ENDPOINTS

Dreamer endpoints

EndpointFunction
POST dreamer/signuplets the user signup
POST dreamer/loginlets the user login
POST dreamer/logoutlets the user logout
GET /dreamer/megets the currently logged in user
GET /dreamergets all existing dreamer
GET /dreamer/usernamegets the user with the specified username
GET /dreamer/username/dreamsgets all dreams by the specified user
**PUT /dreamer/usernameupdates the specified user
**DELETE /dreamer/usernamedeletes the specified user

Dream endpoints

EndpointFunction
*POST /dreams/createlets a user post a dream
GET /dreamsgets all existing dreams
GET /dreams/idgets the dream with the specified id
GET /dreams/id/commentsgets all the comments to the specified dream
*POST /dreams/id/commentspost a comment to the specified dream
**PUT /dreams/idupdates the specified dream
**DELETE /dreams/iddeletes the specified dream

Comment endpoints

EndpointFunction
GET /commentsgets all existing comments
GET /comments/idgets the comment with the specified id
GET /comments/id/repliesgets all the replies to the specified comment
*POST /comments/id/repliespost a reply to the specified comment
**PUT /comments/idupdates the specified comment
**DELETE /comments/iddeletes the specified comment

Reply endpoints

EndpointFunction
GET /repliesgets all existing replies
GET /replies/idgets the reply with the specified id
**PUT /reply/idupdates the specified reply
**DELETE /reply/iddeletes the specified reply

* -> Route is only accessible to logged in users. ** -> Route is only accessible for the specific author/user or an account with staff role.

About

Twitter-like backend api.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Contributors

Languages