fenya123 / forum123

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

116: Add REST endpoint to create new topic #121

Closed EugeneTurkin closed 1 year ago

EugeneTurkin commented 1 year ago

We need an endpoint which will accept a POST request with json body, validate the request and create a new topic 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
{
    "description": "Some description",  # required non-blank string field
    "title": "Some title",  # required non-blank string field
}

Response example

{
    "id": 42,
    "author_id": 18,
    "description": "Some description",
    "title": "Some title",
}

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


PS more about typing we used for @authorized_acces can be read here