fenya123 / forum123

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

Add REST endpoint to get list of users #105

Closed birthdaysgift closed 1 year ago

birthdaysgift commented 1 year ago

We are going to add REST API interface to our forum, and we decided to begin with creating endpoints without authentication. It won't be secure but it will make development process easier. We will add authentication to these endpoints in the future.

We need an endpoint which will return the list of registered users with abitily to sort results. Sorting will be specified via order_by query parameter. order_by should accept a string with two words separated by comma. First word is the name of the sorting field (only username is acceptable for now). Second word is the sorting direction (asc or desc).

Request example:

GET /api/users?order_by=username,asc

Response example:

[ {"id": 42, "username": "bob"}, {"id": 24, "username": "john"} ]

So in the scope of this task we need to create an endpoint GET /api/users which will return list of users info in json format, or 400 if request is not valid.

To validate requests we are going to use reqparse from flask-restx.