# anzii

> Anzii is a backend javascript modular and event-driven framework that is simple, quick to learn and build with.

Latest version **8.0.1** (published 2025-12-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install anzii
pnpm add anzii
yarn add anzii
bun add anzii
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 8.0.1 |
| Published | 2025-12-02 |
| First published | 2019-12-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 17 |
| Unpacked size | 586.7 KB |
| Known vulnerabilities | 0 (+9 in 3 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | IIprodakts |
| Maintainers | iiprodakts |
| Keywords | backend, framework, api, javascript, anzii |

## Links

- npm: https://www.npmjs.com/package/anzii
- Repository: https://github.com/iiprodakts/anzii
- Homepage: https://github.com/iiprodakts/anzii#readme
- Issues: https://github.com/iiprodakts/anzii/issues
- npm.io page: https://npm.io/package/anzii

## Dependencies (17)

- [cors](https://npm.io/package/cors.md) ^2.8.5
- [glob](https://npm.io/package/glob.md) ^10.3.10
- [open](https://npm.io/package/open.md) 8.4.1
- [uuid](https://npm.io/package/uuid.md) ^7.0.2
- [debug](https://npm.io/package/debug.md) ^3.2.6
- [mysql](https://npm.io/package/mysql.md) ^2.16.0
- [config](https://npm.io/package/config.md) ^2.0.2
- [mysql2](https://npm.io/package/mysql2.md) ^2.3.3
- [express](https://npm.io/package/express.md) ^4.16.3
- [winston](https://npm.io/package/winston.md) ^3.2.1
- [jsonfile](https://npm.io/package/jsonfile.md) ^6.2.0
- [passport](https://npm.io/package/passport.md) ^0.4.1
- [portfinder](https://npm.io/package/portfinder.md) ^1.0.32
- [body-parser](https://npm.io/package/body-parser.md) ^1.18.3
- [detect-port](https://npm.io/package/detect-port.md) ^1.5.1
- [promise-mysql](https://npm.io/package/promise-mysql.md) ^3.3.1
- [supports-color](https://npm.io/package/supports-color.md) ^7.1.0

## Alternatives

- [@sveltejs/kit](https://npm.io/package/@sveltejs/kit.md) — 2.2M weekly downloads
- [@atlaskit/theme](https://npm.io/package/@atlaskit/theme.md) — 402.0K weekly downloads
- [@tangle-network/brand](https://npm.io/package/@tangle-network/brand.md) — 10.0K weekly downloads
- [seneca](https://npm.io/package/seneca.md) — 7.4K weekly downloads
- [@bsb/base](https://npm.io/package/@bsb/base.md) — 7.2K weekly downloads

## Recent versions

- 8.0.1 (latest) — 2025-12-02
- 8.0.0 — 2025-11-23
- 7.1.0 — 2024-03-23
- 7.0.0 — 2024-03-17
- 6.0.5 — 2024-03-17
- 6.1.0 — 2023-10-10
- 6.0.0 — 2023-01-27
- 5.0.0 — 2021-05-08
- 4.0.0 — 2021-02-13
- 2.2.12 — 2020-11-13
- 2.2.11 — 2020-11-13
- 2.2.10 — 2020-11-13
- 2.2.9 — 2020-11-12
- 2.2.8 — 2020-11-12
- 2.2.7 — 2020-11-12
- … 21 more at https://npm.io/package/anzii/versions

## README

<p align="center">
	<a href="#" style="
			 display: inline-flex;
			 flex-direction: column;
			 align-items: center;
			 text-decoration: none;
			 color: inherit;
		 ">
		<img src="https://raw.githubusercontent.com/iiprodakts/anzii/refs/heads/development/anzii_white.svg" width="150" alt="Example"> </a>
		
	
</p>

# Introduction

**anzii** is a lightweight, modular, and event-driven Node.js framework for building extensible applications with ease. Perfect for creating APIs, plugins, middleware-based apps, or small web services.

It was designed to be simple, quick to learn and build with. It doesn't matter if you are a designer, developer,or anything in between. If you have a basic understanding of Javascript,you can have your application running in 2 minutes, all with a single line of code.

_If you are upgrading: please see [`UPGRADING.md`](UPGRADING.md)._

# anzii

[![npm version](https://img.shields.io/npm/v/anzii.svg)](https://www.npmjs.com/package/anzii)  
[![License: MIT](https://img.shields.io/npm/l/anzii.svg)](https://github.com/iiprodakts/anzii/blob/master/LICENSE)  
<a href="https://github.com/iiprodakts/anzii/blob/development/.github/workflows/checks.yaml">
<img src="https://img.shields.io/github/actions/workflow/status/iiprodakts/anzii/checks.yaml?style=for-the-badge" alt="anzii license" />
</a>&nbsp;

---

# Features

- **Event-driven architecture** – handle asynchronous workflows elegantly.
- **Plugin-based design** – easily extend functionality with modular plugins.
- **Routing & middleware** – define custom routes and middleware in a clean configuration.
- **Clustering support** – scale your apps across multiple CPU cores.
- **Flexible configuration** – `.config.json` controls routing, middleware, logging, and clustering.

---

# Installation

```bash
npm install anzii
```

# Quick Guide

```js
import { anzii } from "anzii";
anzii(); // Starts anzii server with default configuration
```

## With Plugins

```js
import { anzii } from "anzii";
import HelloPlugin from "./plugins/Hello.js";

const plugins = {
	Hello: HelloPlugin,
};

anzii(plugins);
```

## Configurations

Anzii will look for a `.config.json` configuration in the root of your project. This configuration file is used to configure your preferences for things such _middlewares,routes,static and view directories_,etc

Create a .config.json at your project root:

```js
import routes from "./includes/routes";
import * as middlewares from "./includes/globals";

export default {
	middleware:
		publik: middlewares.public ,
		privet:  middlewares.pprivate ,
		all: middlewares.all ,
	}, // Your middlewares configurations
	view: true, // Enable rendering web pages
	router: routes, // Your api routes
	logger: { level: "info" }, // Enable info logging
	cluster: { workers: 3, spawn: true }, // Enabble cluster
};
```

### Notes

- **middleware** – Load global, public, and private middleware functions.
- **view** – Enable rendering HTML templates or static assets.
- **router** – Define routes and map them to plugin handlers.
- **logger** – Control logging levels (info, warn, error, etc.).
- **cluster** – Scale the server using multiple worker processes.

## Routing Examples

In Anzii, every route is an object that contains a couple of properties that determine charateristics of that route:

```js

   {
        path: '/hello', // Route path with request handler(plugin) name(hello)
        method: 'GET', // Use get method for this route
        type: 'public', // Make this a publicly available path

    },

```

Every route object represents a handler(plugin) whose task is to handle a request in a request/response lifecycle, **more on this shortly**.

## Anzii plugins

### Example Plugin Hello

```js
class Hello {
	constructor(pao) {
		this.pao = pao; // Every plugin is passed this object
	}

	init() {
		this.listens({
			"handle-hello-task": this.handleHelloTask.bind(this), // Event and handling method
		}); // Call listens() method (available to every anzii plugin) to set events that this module  listens to
	} // Define the required init() method

	handleHelloTask(data) {
		const self = this;

		self.callback = data.callback;
		const { payload } = data;
		const { user } = payload;
		const { name, surname } = user; // assume name to be "Ntsako" and surname to be "Mashele"
		const message = `Hello ${name} ${surname}, I'm happy to meet you.'`;
		return self.callback(null, { message: message });
	}
}

export default Hello;
```

And that's it! The thing is done!
Now when you navigate to **_http://localhost:3000/hello_**
you should see the text **_Hello Ntsako Mashele, I'm happy to meet you_**.
on your browser.

### The `data` object

Every `event-handling` method of a plugin receives a `data` argument which contains `data` that the `event-handling` module expects to be able to perform and complete its task. The `data` argument is sent by an `event-emitting` module that is in need of a task that the `event-handling` performs.

In a request/response lifecycle, your `request` handling module/plugin is sent a `data` object that your plugin requires to complete its task. The emitted `data` object contains information needed in a request/response lifecycle. A picture is worth a thousand words, please refer to the `request` `data` object below:

```js

    {
        payload: {

                parsed: {
                    url: '/greeting/Ntsako/Mashele',
                    handler: 'greeting' //
                }, // Request information directly extracted from the request object
                user: { name: 'Ntsako', surname: 'Mashele' }, // Parameters or data extracted
                handler: 'hello', // Request handling plugin name (sometimes refered to as alias)
                request: {

                    req: [IncomingMessage],
                    res: [ServerResponse]
                } // Request and Response objects for further manipulation (using express framework)

        }, // Contains data about the request
        callback: [Function: bound taskerHandler] // Method to be called when task is completed

    }// Data object

```

## How does it work?

Every anzii plugin you create should include an `init()` method whose sole purpose is to call `this.listen()` method. The `this.listen()` method takes an object that contains a list of events that your plugin should listen to. As an An anzii plugin author, you define a list of events that you want to handle when emitters emit them.

Instead of listening to `events`, sometimes you create plugins that emit those events,in which case your listeners have to know about your events in order to listen to them to perform whatever task they exist to perform.

The anzii framework is its self made up of plugins building upon its base. These plugins also emit and listen to certain events.

As authors of these plugins/modules, we have defined specific events that we expect interested consumers(listeners) to listen and handle. One of these events is used in the request/response lifecycle and it takes the form `handle-pluginname-task`. This event is emitted whenever a request is made to a server running anzii.

Any plugin you implement to handle a request should listen to the event of the form `handle-pluginname-task` where `pluginname` refers to the name of your plugin.

In the `Hello` example above,the request is handled by the `Hello` plugin,so the plugin listens to the `handle-hello-task` event.

## Route Alias

There are cases where you find the use of a `handler` as part of the route object's `path`property is undesired. In such a case, you can use a `route Alias` by adding an `alias` property in the `route` object with the name of the handler as the value of the property. **See an example below**.

Using the `Hello` example above, the `route` object with an `alias` will be written this way:

```js

    {

        path: '/greeting',
        type: 'public',
        alias: 'hello'

    }

```

# Documentation

Docs coming soon!

we are currently working on our documentation with the help from our first ever collaborater @ntsakosuprise

# Questions & Support

For questions and support please use anziijs's Suppport page on [Github repo](https://github.com/iiprodakts/anzii/development/SUPPORT.md).

# Issues

Please make sure to read the [Issue](https://github.com/iiprodakts/anzii/development/ISSUES.md) Reporting Checklist before opening an issue. Issues not conforming to the guidelines may be closed immediately.

# Changelog

Detailed changes for each release are documented in our [Changelog](https://github.com/iiprodakts/anzii/development/CHANGELOG.md).

# Release Notes

A summary of release changes can be found in our [Release Notes](https://github.com/iiprodakts/anzii/development/RELEASE_NOTES.md).

# Stay In Touch

[Twitter @anziijs](https://twitter.com/anziijs).

# Contribution

Please make sure to read the [Contributing Guide](https://github.com/iiprodakts/anzii/development/CONTRIBUTING.md) before making a pull request. If you have an anzii plugin, add it with a pull request.

# Licence

[MIT](https://.github.com/) - see the [LICENSE](https://github.com/iiprodakts/anzii/development/LICENSE.md) file for details.

copyright (c) 2019-present, iiprodatks. Ntsako (Surprise) Mashele

A Special thanks to Nicholas C. Zakas for the box presentation that help inspire Akii which has inspired anzii.

---
_Source: https://npm.io/package/anzii · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
