Command line challenge from TrueLayer to output top posts from Hackers News in an API format.
npm install
node server.js hackernews --posts n
n refers to a positive integer <= 100
npm test
- request: an easy, clean way to make http calls
- request-promise: builds on the above but comes with promise support
- mocha: testing framework for node. Easy to use, provides accurate reporting and a large community to support it.
- chai: an assertion library to help verify results. Has great documentation
While I feel I managed to hit all the requirements, my testing could be improved upon mainly with server calls and handling promises.
_______________________________________________________________________________________________________________________
At TrueLayer we love to stay up to date with what is hot in technology and we read Hacker News every day.
In order to make it more fun to read for robots (and easier to integrate in our workflow) we would like to write a simple command line application that would output to STDOUT
the top posts in JSON
[
{
"title": "Web Scraping in 2016",
"uri": "https://franciskim.co/2016/08/24/dont-need-no-stinking-api-web-scraping-2016-beyond/",
"author": "franciskim",
"points": 133,
"comments": 80,
"rank": 1
},
{
"title": "Instapaper is joining Pinterest",
"uri": "http://blog.instapaper.com/post/149374303661",
"author": "ropiku",
"points": 182,
"comments": 99,
"rank": 2
}
]
We expect the application to take these arguments:
hackernews --posts n
--posts
how many posts to print. A positive integer <= 100.
title
andauthor
are non empty strings not longer than 256 characters.uri
is a valid URIpoints
,comments
andrank
are integers >= 0.
Feel free to use any language framework and library you want. Make it concise, readable and correct.
- how to run it (don't assume anything already installed)
- what libraries you used and why
- unit tests
- robust input checking
- good comments
- Dockerfile
Have fun, take your time and when you are done please send a link to your public Github repo at join@truelayer.com