fenya123 / forum123

Flask application written for educational purposes.
http://193.124.115.171/
1 stars 1 forks source link

Add REST endpoint to create new post #120

Closed birthdaysgift closed 1 year ago

birthdaysgift commented 1 year ago

We need an endpoint which will accept a POST request with json body, validate the request and create a new post in db. author_id field should be filled by user id from JWT token. We should return 400 if request isn't valid. We should return 401 if JWT token isn't provided. We should return 403 if user from JWT token was not found in database.

Request example

POST /topics/42/posts
{
    "body": "Some post body"  # required non-blank string field
}

Response example

{
    "id": 42,
    "author_id": 18,
    "body": "Some post body",
    "topic_id": 24,
}

So in the scope of this task we need to create endpoint which will create a new post and return info about it.