This is a REST API news web server, runs on warp, uses wai and PostgreSQL DBMS. It has no frontend, so it only responds in raw JSON data. Server starts at http://localhost:8080/.
- Supports pagination. To receive paginated data provide query parameters of limit and offset. Example: ?limit=15&offset=0.
- Supports filtering:
- By date created. Get news posted at exact date with ?created_at, or posted earlier with ?created_at_lt, or posted later with ?created_at_gt.
- By author name (case ignored) with ?author_name.
- By category id with ?category_id.
- By tag id. Get posts with exact tag with ?tag_id, including some tags in a list with ?tag_id_in, including all tags in a list with ?tag_id_all.
- By phrase in title (case ignored) with ?title_has.
- By phase in content (case ignored) with ?content_has.
- Supports sorting with ?sort_by:
- By author name ?sort_by=author.
- By category name ?sort_by=category.
- By date created ?sort_by=date.
- By number of photos ?sort_by=photos.
- Finds search query in content or in a author/tag/category name.
- Supports pagination. To receive paginated data provide query parameters of limit and offset. Example: ?limit=15&offset=0.
- Supports sorting with ?sort_by:
- By author name ?sort_by=author.
- By category name ?sort_by=category.
- By date created ?sort_by=date.
- By number of photos ?sort_by=photos.
- Gets comments to a specific post by its id.
- Supports pagination. To receive paginated data provide query parameters of limit and offset. Example: ?limit=15&offset=0.
- api/authors
- api/users
- api/tags
- api/categories
- api/authors 🚫
- api/users
- api/tags 🚫
- api/categories 🚫
- api/posts
- api/posts/1/comments
- POST api/posts/1 🆔
- api/authors/1 🚫
- api/tags/1 🚫
- api/categories/1 🚫
- api/posts/1 🆔
- api/authors/1 🚫
- api/users/1 🚫
- api/tags/1 🚫
- api/categories/1 🚫
- api/posts/1 🆔
- api/comments/1 🆔
- Authorization is accomplished by providing user id in Authorization header.
- Paths which require admin authorization are marked by 🚫.
- Paths which require authorization by author are marked by 🆔.
Supported levels of logging are: Debug, Info, Warn, Error, the log writes to <./logs/news-server.log> by default.
Configuration file is <./conf/configuration.local>. Configure database connection, pagination and logging. For convenience there is <./conf/configuration.template> file in the repository, that could be used for reference.
To build an executable use <stack build> command.
Use <stack repl> command to load project in interactive mode, then call initializeDB function. SQL files in <./migrations> will be then executed in alphabetical order. Note that you have to configure connection at <./conf/configuration.local> and create database first (for example with psql).
To test project use <stack test> command. Curl tests are located at <./curl/>, use <./curl/run-tests.sh> to run them all.
To launch app use <stack exec news-rest-api-exe> command.