Running node.js code in 2 mouse clicks using haiku-http

Hero Image

If you are reading this, you have obviously clicked already once to get to this post. So you only have 1 click left – use it on one of the sample links below.

Then you can experiment more with haiku-http, read about haiku-http vision and design, or get the code on GitHub.

Hello, world

Here is the ‘Hello, world’ rite of passage:

res.end('Hello, world!\n')

War and peace

How many times do the words “war” and “peace” appear on today?



var query = require('url').parse(req.url, true).query  
var word = query.word || 'the'  
var request = require('request')  
request('', function (error, response, body) {  
    if (error || response.statusCode !== 200) {  
        res.end('Unexpected error getting\n')  
    else {  
        var count = 0, index = 0  
        while (0 !== (index = (body.indexOf(word, index) + 1)))  
        res.end('Number of times the word "' + word + '" occurs on is: ' + count + '\n')  

Fetch data from MongoDB

Return documents from MongoDB that match search criteria.

All documents:

Only documents for ‘’ host:

var query = require('url').parse(req.url, true).query  
var mongoUrl = query['db'] || 'mongodb://'  
var filter = query['host'] ? { hosts: query['host'] } : {}  
require('mongodb').connect(mongoUrl, function (err, db) {  
    if (notError(err))  
        db.collection('apps', function (err, apps) {  
            if (notError(err))  
                apps.find(filter).toArray(function (err, docs) {  
                    if (notError(err)) {  
function notError(err) {  
    if (err) {  
    return !err  

Time for more

Experiment more with haiku-http, read about haiku-http vision and design, or get the code on GitHub.

Comments welcome!


Related Content

2 February 2022
fetch() In Node.js Core: Why You Should Care

Node 17.5 introduces support for the fetch() HTTP client, a new way to send requests to HTTP APIs.

23 February 2022
Node.js Adds Support for Direct Registry-less HTTPS Imports

Node is planning to introduce support for HTTPS imports in Node 18 - a feature that enables you to use urls to directly import modules over HTTPS into your project.

15 February 2022
Run Every Node.js Version in AWS Lambda

Run any version of Node.js in AWS Lambda within hours after release using custom AWS Lambda runtimes from Fusebit