All Articles

Introducing Koii

Happy holidays!

Koi Fish

I took some time off social media and decided to spend it doing something worthwhile such as contributing to open source projects. Recently, I was working on a gig with a friend of mine where we made use of HapiJS instead of ExpressJS (your thought might be HapiJS? What is that? — It’s one of the many Javascript frameworks you have or will hear about, that’s just one of the perks of being a Javascript developer) and since then I’ve fallen in love with the HapiJS community which led me to contribute to the Joi validation library some months back.

So, Why Koii?

Koii originally named Koi (had to change the name because it’s already taken by someone else 😣) is an ExpressJS middleware used to print all routes accessible in an application to the console on start. I’ve always struggled when I jump on an existing project and I have to start figuring out the routes that exist and how to access them. Postman collections are a good workaround for folks that struggle with something like this but I created Koii because seeing the available routes on the terminal after every reload is easier for me.

The idea for Koii was gotten from Danielb2’s Blipp plugin for HapiJS, all I did was create an expressJS variant for it.

Screenshot of Blipp in an HapiJS project


Setting up Koii in an application is very easy and all it takes is just 3 steps:

  1. Install Koii This can be done by entering the command (depending on the package manager of your choice) in the terminal.

    npm install koii


    yarn add koii
  2. Instruct ExpressJS to use the Koii middleware This is as simple as adding the statement


    to your application. A sample snippet is shown below:

    'use strict';
    const express = require('express');
    const koii = require('koii');
    const app = express();
    const PORT = 3103;
    app.get('/', function (req, res) {
    return res.send({ status: 'success', message: 'Sample express application' });
    app.listen(PORT, function () {
    console.log('Application running on port ' + PORT);
    view raw koii.js hosted with ❤ by GitHub

Ensure the instruction to use the Koii middleware is placed at the end of your route definition so the middleware can have access to your defined routes.

And voila, you should see something similar to the screenshot below once you start your ExpressJS application.

Screenshot of Koii in a sample project

Feel free to check out the project on Github and leave some stars (it helps to know that people are using the tools I build, that will help me focus more on building more 😏).