npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

koalla

v0.1.4

Published

CLI for building Koalla backends.

Downloads

3

Readme

What is Koalla?

Koalla is a simple and lean project scaffolding for building Node.js Web APIs.

It aims to be a sane middleground between the dozen scattered options of super-opinionated back-end frameworks such as Nest.js and Adonis, and the super-loose "figure everything by yourself" standalone frameworks like Koa.js and Express.js.

There is nothing wrong with either super-opinionated or super-loose frameworks, but they're not for everybody.

If you like to have a sane base to build up your API, that gives you the basics to get going while also keeping all your freedom to change whatever you like, then Koalla may be a good fit for you.

Features

  • 🌿 Performance: Uses Koa as web framework & router.
  • 🌿 Tests: Uses uvu for blazing fast™ unit & endpoints testing.
  • 🌿 Safety: TypeScript by default.
  • 🌿 Flexibility: No enforced patterns other than routes filenames.
  • 🌿 Comfort: Live-reload out of the box.
  • 🌿 Productivity: A minimal CLI that generates endpoints for you.
  • 🌿 Docs: Add some comments to your routes and get Swagger docs.

Getting started

To get started with Koalla, simply run:

npx koalla init my-project

And that's it! You now have the base for your new back-end ready to go with all the above features in less than 10 seconds!

Creating routes

To create a new route you can use the new route command:

npx koalla new route products

This command will generate two files for you:

  • src/endpoints/products.ts
  • src/routes/products.ts

Endpoints

Endpoints are where you'll put your endpoints logic. A typical file looks like this:

import { RouterContext } from "@koa/router";
import Koa from "koa";

export const ExampleEndpoints = {
  async read(ctx: Koa.Context & RouterContext, next: Koa.Next) {
    ctx.status = 200;
    ctx.body = {
      message: "Hello!",
    };
    next();
  },
};

This is the pattern Koalla and the CLI uses, but you're free write those files as you please. As long as your function (or class method) receives Koa's ctx and next and keep compliance, everything else is allowed.

Routes

Routes are where you'll find the path that runs your endpoints. A typical file looks like this:

import Koa from "koa";
import Router, { RouterContext } from "@koa/router";
import { ExampleEndpoints } from "@/endpoints/example";

const router = new Router();
router.get("/", ExampleEndpoints.read);

export default router.routes();

Alternatively, you can enable swagger docs by adding a few comments:

import Koa from "koa";
import Router, { RouterContext } from "@koa/router";
import { ExampleEndpoints } from "@/endpoints/example";

const router = new Router();
router.get(
  "/",
  async (ctx: Koa.BaseContext & RouterContext, next: Koa.Next) => {
    /*
    #swagger.tags = ['Example']
    #swagger.responses[200] = {
      schema: {
        message: "Hello.",
      }
    }
    */

    return ExampleEndpoints.read.call(this, ctx, next);
  }
);

export default router.routes();

Koalla uses swagger-autogen, visit the docs for further instructions on all the available comments.

Special Thanks

Koalla can be described simply as a smart backpack with cool tools inside it organized and ready for you to use.

This means Koalla wouldn't be possible without the great efforts of those tools: