Skip to content

snorlacs/Newse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Newse - Backend service for reading news articles

Starting the application

./gradlew run

Once the application is started, it can be reached at

http://localhost:8080

Endpoints

The following are the rest endpoints:

HTTP Verb URL Description Status Codes
GET http://localhost:8080/article/{id} Gets the article corresponding to the supplied article ID
  • 200 OK if article exists
  • 404 Not Found if article does not exist
GET http://localhost:8080/articles?keyword={keyword}&author={author}&from={fromDate}&to={toDate}
  • Gets the list of articles matching the provided query params
  • gets all articles if no query params are provided, all query params are optional
  • date format is yyyy-MM-dd'T'HH:mm:ss.SSSZ
  • 200 OK if article exists
  • 404 Not Found if article does not exist
POST http://localhost:8080/article Creates a new article based on the payload contained in the request body and basic auth
  • 201 Created if article successfully created
  • 401 Unauthorized If it is not editor
PUT http://localhost:8080/article/{id} Updates an existing article with the data contained in the request body
  • 200 OK if article successfully updated
  • 404 Not Found if article does not exist
  • 401 Unauthorized If it is not editor
DELETE http://localhost:8080/article/{id} Deletes an existing article that corresponds to the supplied article ID
  • 204 No Content if article successfully deleted
  • 404 Not Found if article does not exist
  • 401 Unauthorized If it is not editor

Request Body for POST api

{
   "header" : "Header for the article",
   "short-description": "A short description of the article",
   "text": "The content of the article",
   "publishedOn": "Publish date of the article, format yyyy-MM-dd'T'HH:mm:ss.SSSZ",
   "authors": "List of authors of the article Eg: [{name:"author1"},{name: "author2"}]"
   "keywords": "List of keywords for article Eg: ["keyword1", "keywords2"]"
}

Constraint: None of the above fields can be empty, all are mandatory

Some more Gradle commands

To build the application
`./gradlew build`     

To run all tests
`./gradlew test`

Authorization

  • Uses basis access authentication to differentiate between an editor and user
    • Improvement is to use OAuth2.0 based authorization, which is more secured since basic auth is vulnerable because the authorization is set in the header.
  • Credentials are stored in properties file, which will be a devops automation generated file in prod.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published