DEV Community

Cover image for Ever wanted to see what's your service doing?
Ivan Kalatchev
Ivan Kalatchev

Posted on

Ever wanted to see what's your service doing?

Have you ever wanted to see what's your service doing? To see what is it requesting and/or sending? Well, I've asked myself these questions a fair number of times, and finally I've pushed myself to create a very little Node.JS application, solving these exact problems. So naturally this will be a very fast and simple post about it.

It's honestly so simple, it blows my mind how well it's working.

My application is called TestYourService, hosted on GitHub uploaded to NPM, so anyone could see how it is working, or just use it to their hearts content. I won't bother you with more irrelevant information, so let me just show you how to use it...


Firstly we need to install it. This can be done by either downloading the executable from GitHub, or (and I recommend this option) install it globally from NPM.

npm i -g testyourservice
Enter fullscreen mode Exit fullscreen mode

Then we can simply call it, again trough the console... Oh and I hope you are running on windows. ;)

testyourservice-win
Enter fullscreen mode Exit fullscreen mode

Image description

Now all that is left to do is to use the fucking thig!

Image description

With all that said, I hope my little tool helps you trough this magical journey called "Developing a service"!


And just for the curios ones, here is the main peace of code, should you try to create something like that on your own. :)


var http = require('http');

console.log("\x1b[31m", "testyourservice running on port 1025")

http.createServer(function (req, res) {

    console.log("\x1b[37m", req.method + " -> " + req.url);

    if (req.method == "POST") {
        req.on('data', chunk => {
            console.log(`Data chunk available: ${chunk}`)
        })
    }

    res.statusCode = 200;
    res.end();
}).listen(1025);

Enter fullscreen mode Exit fullscreen mode

Top comments (0)