/async-lab

Efficiently use different async techniques to solve async problems

Primary LanguageJavaScript

Purpose

The purpose of this repo is to efficiently use different async techniques in solving the following problem.

Currently the problem is being successfully implemented using node.js callbacks, async.js waterfall and promises and rxjs observables.

More problems will be added soon.

Problem

Create a node server which responds to one and only one route : GET /I/want/title

This route expects a list of websites addresses in query string format e.g.

/I/want/title/?address=google.com
/I/want/title/?address=http://yahoo.com
/I/want/title/?address=google.com&address=www.dawn.com/events/

etc.

The number of addresses can be more than one.

The route will make request to each of the address passed to it. It will parse out the <title></title> tags, render them in html and send back the html in response. e.g. the response to above #3 example would be:

<h1> Following are the titles of given websites: </h1>

<ul>
   <li> google.com - "Google" </li>
   <li> www.dawn.com/events/ - "Events - DAWN.COM" </li>
</ul>
For all other routes, the server should return HTTP code 404 .

Please make sure to add error handling e.g.

/I/want/title/?address=asdasdasd should return

  • asdasdasd - NO RESPONSE