# IT Kamianets API Framework: packages

Every package of the IT Kamianets API Framework (also called API ITKP): what it does, what it depends on, and how to install it. Use this file to choose packages for a new back-end API.

- Website: https://api.itkamianets.com
- Source: https://github.com/WebArtWork
- This file: https://api.itkamianets.com/packages.md (generated from the website catalog on every build)

8 packages: 1 runtime, 2 core, 5 modules. 2 constructors, 1 API.

## How the framework is built

```text
runtime            waw                  loads config and modules
core               waw-core, waw-sem    the CLI and the server engine
modules            waw-<feature>        users, forms, translations, files, Telegram
constructors       waw-default, ...     starter repositories, one per API stack
your API           server/<module>      your own modules, config and data
```

Each layer uses only the layers above it in this list. Business logic stays in your API's modules; a module that more than one API could use belongs in the framework instead, as `waw-<feature>`.

## Using packages

**Start an API from a constructor.** Clone its starter repository under your API's name and follow its README.

**Add a module to an API.** waw modules are listed in the project's `config.json` under `modules`, and waw installs them from GitHub. Packages that are on npm install with `npm install <npm name>`. Node.js 24 LTS.

**Change a framework module through a pull request** on its repository. Full flow: https://api.itkamianets.com/docs/build-an-api

## Packages at a glance

### Runtime

The module loader every API runs on: config, modules and their order.

| Package | What it does | Depends on |
|---|---|---|
| [`waw`](#waw) | The waw command and module loader: reads the config, finds modules, installs their dependencies, orders them and runs either a CLI command or the runtime. | - |

### Core

The CLI and the server engine: Express, MongoDB, sessions, Socket.IO and CRUD.

| Package | What it does | Depends on |
|---|---|---|
| [`waw-core`](#waw-core) | The default CLI of every waw project (new, add, sync, start, stop) and two runtime helpers: waw.wait and waw.http. | `waw` |
| [`waw-sem`](#waw-sem) | The server engine: Express, MongoDB with Mongoose and sessions, Socket.IO and a CRUD generator driven by module.json. | `waw`, `waw-core` |

### Modules

Feature modules an API adds when it needs them, each one a waw module.

| Package | What it does | Depends on |
|---|---|---|
| [`waw-user`](#waw-user) | Sign-up and sign-in with email and password or Google, JWT in a cookie or header, password reset, roles and user CRUD. | `waw-sem` |
| [`waw-form`](#waw-form) | Dynamic form definitions for front ends: forms and nested components, scoped by domain or app id. | `waw-sem`, `waw-user` |
| [`waw-translate`](#waw-translate) | An early translation module: a Translate collection as a cache and a small DeepL helper. No working public routes yet. | `waw-sem` |
| [`waw-cloudflare`](#waw-cloudflare) | Files on Cloudflare R2: presigned browser uploads, server base64 uploads, public or signed URLs, deletion and a CLI. | `waw-sem`, `waw-user` |
| [`waw-telegram`](#waw-telegram) | A Telegram bot (grammY) and a contact route that forwards site messages to the right Telegram chat. | `waw-sem` |

## Constructors

A constructor is a starter repository for one kind of API, one per stack: waw today, NestJS planned.

### waw API

The starter for back-end APIs on waw. It is a waw project with core and sem from npm and five ready local modules: user, form, cloudflare, telegram and translate. Create it with waw new or clone it, set config.json and run waw.

| | |
|---|---|
| Kind | A Node.js API on waw, Express and MongoDB |
| Status | released |
| Built with it | it.webart.work |
| Starts with | [`waw`](#waw), [`waw-core`](#waw-core), [`waw-sem`](#waw-sem), [`waw-user`](#waw-user) |
| Adds when needed | [`waw-form`](#waw-form), [`waw-cloudflare`](#waw-cloudflare), [`waw-telegram`](#waw-telegram), [`waw-translate`](#waw-translate) |
| Your project | `<project>-api` |
| Starter repository | https://github.com/WebArtWork/waw-default |
| Page | https://api.itkamianets.com/constructors/waw |

### NestJS API

A planned starter for teams that want NestJS and TypeScript instead of waw. Work has not started: there is no repository yet, and its stack and contents are not decided.

| | |
|---|---|
| Kind | A TypeScript API on NestJS |
| Status | planned |
| Built with it | - |
| Starts with | - |
| Adds when needed | - |
| Your project | `<project>-api` |
| Starter repository | https://github.com/WebArtWork/nest-default |
| Page | https://api.itkamianets.com/constructors/nest |

## APIs

APIs built on the framework. Their own modules live outside this catalog.

### it.webart.work

One waw back end for many products: company sites and their admin panels, shops and restaurant apps, project workflows, files and generated images, payments, delivery, quantum computing experiments and MCP servers for AI assistants. Almost everything lives in local modules under server/, on waw-core and waw-sem. Its route reference is published at it.webart.work/docs.

| | |
|---|---|
| Status | released |
| Constructor | waw API |
| Framework packages | [`waw`](#waw), [`waw-core`](#waw-core), [`waw-sem`](#waw-sem), [`waw-user`](#waw-user), [`waw-form`](#waw-form), [`waw-cloudflare`](#waw-cloudflare), [`waw-telegram`](#waw-telegram), [`waw-translate`](#waw-translate) |
| Own modules | `user`, `company`, `form`, `pay`, `cloudflare`, `asset`, `assetra`, `quantum`, `telegram`, `mcp`, `docs` |
| Clients | ngx-bos (https://github.com/WebArtWork/ngx-bos), ngx-default (https://github.com/WebArtWork/ngx-default), ngx-horeca (https://github.com/WebArtWork/ngx-horeca), webart.work (https://webart.work), Assetra site (https://assetra.itkamianets.com) |
| Page | https://api.itkamianets.com/apis/it-webart-work |

## Runtime

The module loader every API runs on: config, modules and their order.

### waw

The waw command and module loader: reads the config, finds modules, installs their dependencies, orders them and runs either a CLI command or the runtime.

| | |
|---|---|
| npm | `@wawjs/cli` |
| Status | v26.1.2 |
| Depends on | nothing |
| Used by | [`waw-core`](#waw-core), [`waw-sem`](#waw-sem) |
| Repository | https://github.com/WebArtWork/waw |
| Page | https://api.itkamianets.com/packages/waw |

**Purpose.** Every API built on the framework starts from waw. The loader itself is deliberately tiny: it knows nothing about Express, MongoDB or routes. It merges the global and project config, discovers local modules in the server folder and global modules listed in config.json, installs each module's npm dependencies into that module's own folder, sorts modules by their before and after rules, and then either dispatches a command from a module's cli.js or loads every module's index.js with one shared waw object. Everything else comes from modules.

**Usage.** Install the command globally and run waw in the project folder. Without arguments it starts the runtime; with a command, such as waw add, it runs the cli.js of the module that defines it. List global modules in config.json under modules, and keep secrets in server.json.

**Includes:**

- Published on npm as @wawjs/cli 26.1.2; the command is still waw. The older unscoped waw package stops at 26.1.0.
- Merges config in this order, later wins: global config.json, global server.json, project config.json, project server.json.
- Global module sources: waw and itkp (GitHub repositories named waw-<name>), npm (@wawjs/waw-<name>) or any npm package name.
- Runs the production API it.webart.work.

**API:**

| Member | What it does |
|---|---|
| `config.json modules` | Map of global modules to their source: waw, itkp, npm or an npm package name. |
| `module.json` | A module's manifest: dependencies, before, after and priority, plus fields other modules read, such as crud. |
| `index.js` | The module's runtime entry: an async function that receives the shared waw object. |
| `cli.js` | The module's CLI commands, dispatched by the first argument of waw. |
| `waw.config` | The merged config of the global install and the project. |
| `waw.modules` | The loaded modules in their final order, with their paths and file lists. |

**Example:**

```js
// config.json
{
	"name": "My API",
	"port": 8080,
	"modules": { "core": "npm", "sem": "npm" }
}

// server/hello/index.js
module.exports = async (waw) => {
	console.log(`${waw.config.name} is starting`);
};
```

**Install:**

```text
npm install @wawjs/cli
```

Requirements:

- Node.js 24 or later
- npm in PATH
- git, for global modules synced from GitHub

## Core

The CLI and the server engine: Express, MongoDB, sessions, Socket.IO and CRUD.

### waw-core

The default CLI of every waw project (new, add, sync, start, stop) and two runtime helpers: waw.wait and waw.http.

| | |
|---|---|
| npm | `@wawjs/waw-core` |
| Status | v26.0.2 |
| Depends on | [`waw`](#waw) |
| Used by | [`waw-sem`](#waw-sem) |
| Repository | https://github.com/WebArtWork/waw-core |
| Page | https://api.itkamianets.com/packages/waw-core |

**Purpose.** waw-core is the first module waw loads. It gives a project the commands people use every day: create a project from a template, add a module, sync modules with their repositories, run the API under PM2 and print the merged agent instructions. It stays small on purpose: Express, MongoDB, routing, CRUD and sessions belong to waw-sem and to project modules.

**Usage.** Declare core in config.json under modules: "npm" installs @wawjs/waw-core from npm, "waw" syncs it from GitHub. Then use the commands in the terminal and waw.wait and waw.http in your modules.

**Includes:**

- Published on npm as @wawjs/waw-core 26.0.2.
- Commands: new, add, css, sync, asset, start, stop, restart, version, ai, wipe and update.

**API:**

| Member | What it does |
|---|---|
| `waw new <name> [repo]` | Creates a project from a template repository. |
| `waw add <name>` | Adds a module to the project; in an API project waw-sem's version creates api.js, the collection and module.json. |
| `waw sync [message]` | Without a message, overwrites modules from their repositories; with one, publishes the module. |
| `waw start \| stop \| restart` | Controls the API process through PM2. |
| `waw version` | Prints the install path, the version and the modules waw can see. |
| `waw ai` | Prints the merged agent instructions of the project. |
| `waw.wait(ms)` | Returns a promise that resolves after ms milliseconds. |
| `waw.http(hostname, port)` | A small client with get, post, put, patch, delete and editable headers. |

**Example:**

```js
npm install -g @wawjs/cli
waw new my-api 1     # 1 = waw Server (waw-default)
cd my-api
waw                  # development
waw add project      # new module in server/project
waw start            # production under PM2
```

**Install:**

```text
npm install @wawjs/waw-core
```

Requirements:

- Node.js 24 or later
- The waw command (@wawjs/cli)
- sharp, only for waw asset

### waw-sem

The server engine: Express, MongoDB with Mongoose and sessions, Socket.IO and a CRUD generator driven by module.json.

| | |
|---|---|
| npm | `@wawjs/waw-sem` |
| Status | v26.0.1 |
| Depends on | [`waw`](#waw), [`waw-core`](#waw-core) |
| Used by | [`waw-user`](#waw-user), [`waw-form`](#waw-form), [`waw-translate`](#waw-translate), [`waw-cloudflare`](#waw-cloudflare), [`waw-telegram`](#waw-telegram) |
| Repository | https://github.com/WebArtWork/waw-sem |
| Page | https://api.itkamianets.com/packages/waw-sem |

**Purpose.** waw-sem turns an ordered set of modules into a running API. It starts Express and the HTTP server, connects MongoDB when config.mongo is set and stores sessions there, opens Socket.IO, then loads every *.collection.js file (models) before every *.api.js file (routes). A crud block in a module's module.json becomes ready routes under /api/<name>, and waw.crud.config lets the module decide who may call each action and what they see.

**Usage.** Add sem next to core in config.json and set port and mongo. Put models in *.collection.js, routes in api.js or *.api.js, and declare conventional CRUD in module.json. Override access and queries per action with waw.crud.config. GET /status returns true when the server is up.

**Includes:**

- Published on npm as @wawjs/waw-sem 26.0.1.
- Express 5, Mongoose 9 and Socket.IO 4, installed into the module's own folder.
- Serves every route of it.webart.work.

**API:**

| Member | What it does |
|---|---|
| `waw.router(basePath)` | Mounts an Express router at the path and returns it. |
| `waw.crud.config(part, config)` | Overrides required, ensure, query, sort, skip, limit, select or populate for each CRUD action. |
| `waw.ensure` | Middleware that lets through only signed-in users. |
| `waw.role(roles, middleware)` | Middleware that checks the user's role flags. |
| `waw.next, waw.block` | Middleware that always allows or always refuses. |
| `waw.mongoose` | The Mongoose instance for models in *.collection.js. |
| `waw.socket.emit(event, payload, room)` | Sends a Socket.IO event to all clients or to one room. |
| `waw.app, waw.server, waw.express` | The Express app, the HTTP server and Express itself. |

**Example:**

```js
// server/project/module.json
{
	"name": "Project",
	"crud": {
		"unique": ["url"],
		"update": { "keys": ["name", "description", "data"] },
		"delete": [""]
	}
}

// server/project/api.js
module.exports = async (waw) => {
	waw.crud.config("project", {
		get: { ensure: waw.next, query: () => ({}) },
		update: { ensure: waw.role("admin"), query: (req) => ({ _id: req.body._id }) },
	});
};
```

**Install:**

```text
npm install @wawjs/waw-sem
```

Requirements:

- Node.js 24 or later
- waw-core, loaded before it
- MongoDB, only when config.mongo is set

## Modules

Feature modules an API adds when it needs them, each one a waw module.

### waw-user

Sign-up and sign-in with email and password or Google, JWT in a cookie or header, password reset, roles and user CRUD.

| | |
|---|---|
| npm | not on npm |
| Status | released |
| Depends on | [`waw-sem`](#waw-sem) |
| Used by | [`waw-form`](#waw-form), [`waw-cloudflare`](#waw-cloudflare) |
| Repository | https://github.com/WebArtWork/waw-user |
| Page | https://api.itkamianets.com/packages/waw-user |

**Purpose.** Most APIs need to know who is calling. waw-user loads before every other project module and sets req.user from a JWT in the authToken cookie or the token header, so later routes can use waw.ensure and waw.role. Roles are flags in user.is, re-read from MongoDB, so a removed role stops working before the token expires.

**Usage.** Not on npm: copy it into the project with waw add waw-user, or list "user": "waw" in config.json modules to sync it from GitHub. Set user.is to give roles to emails, mail for reset codes and firebase.projectIds for Google sign-in. Keep the signing key and mail credentials in server.json.

**Includes:**

- Runs in it.webart.work and ships in waw-default as server/user.
- The WebArtWork/waw-user repository holds an older version (last updated in 2024) with plans and features; the production version lives in those projects.

**API:**

| Member | What it does |
|---|---|
| `POST /api/user/sign` | Registers with email and password and sets the cookie. |
| `POST /api/user/login` | Signs in with email and password. |
| `POST /api/user/firebase` | Signs in or creates an account from a Firebase ID token of a verified Google account. |
| `POST /api/user/request, /api/user/change` | Mails a reset code, then sets a new password with it. |
| `GET /api/user/verify` | Returns the current user or false. |
| `GET /api/user/logout` | Clears the cookie. |
| `/api/user/fetchme, /api/user/update` | Reads and updates the signed-in user's own profile. |

**Example:**

```js
// config.json
{
	"modules": { "core": "npm", "sem": "npm", "user": "waw" },
	"user": { "is": { "admin": "owner@example.com" } }
}

// any module's api.js
module.exports = async (waw) => {
	const router = waw.router("/api/report");
	router.get("/mine", waw.ensure, async (req, res) => res.json(req.user._id));
	router.post("/secret", waw.role("admin"), async (req, res) => res.json(true));
};
```

**Install:**

waw add waw-user

Requirements:

- MongoDB
- An SMTP server, for password reset mail
- Firebase projects, for Google sign-in

### waw-form

Dynamic form definitions for front ends: forms and nested components, scoped by domain or app id.

| | |
|---|---|
| npm | not on npm |
| Status | released |
| Depends on | [`waw-sem`](#waw-sem), [`waw-user`](#waw-user) |
| Used by | nothing in the framework |
| Repository | https://github.com/WebArtWork/waw-form |
| Page | https://api.itkamianets.com/packages/waw-form |

**Purpose.** Front ends such as the Angular form builder in the ngx packages keep their forms in the API instead of in code. A form has a title; its components are nested building blocks with a key, props and child components. Every form belongs to a site through its domain or an appId, so one API serves forms for many sites. Reading is public and changing is admin only.

**Usage.** Not on npm: copy it with waw add waw-form or list "form": "waw" in config.json modules. Front ends read forms with GET /api/form/get?appId=..., and admins edit them through the generated update routes.

**Includes:**

- Runs in it.webart.work and ships in waw-default as server/form.
- The WebArtWork/waw-form repository has an older version with a single collection; formcomponent exists only in the production copies.

**API:**

| Member | What it does |
|---|---|
| `GET /api/form/get` | Public: the forms of an appId, or of the request host. |
| `POST /api/form/fetch` | Public: one form by _id. |
| `POST /api/form/create, update, delete` | Admin only: manage forms. |
| `/api/formcomponent/*` | The same routes for form components. |

**Example:**

```js
// server/form/module.json (crud part)
"crud": [
	{ "name": "form", "update": { "keys": ["title"] }, "delete": [""] },
	{ "name": "formcomponent", "update": { "keys": ["name", "key", "props", "components"] }, "delete": [""] }
]

// a front end
const forms = await fetch("https://api.example.com/api/form/get?appId=my-app").then((r) => r.json());
```

**Install:**

waw add waw-form

Requirements:

- MongoDB
- waw-user, for the admin role

### waw-translate

An early translation module: a Translate collection as a cache and a small DeepL helper. No working public routes yet.

| | |
|---|---|
| npm | not on npm |
| Status | in progress |
| Depends on | [`waw-sem`](#waw-sem) |
| Used by | nothing in the framework |
| Repository | https://github.com/WebArtWork/waw-translate |
| Page | https://api.itkamianets.com/packages/waw-translate |

**Purpose.** waw-translate is where translation features for waw APIs belong. Today it is a starting point: a Translate collection meant to cache the original text, the target language and the translation, a router at /api/translate with no handler yet, and a helper that calls the DeepL API.

**Usage.** Not on npm: copy it with waw add waw-translate or list "translate": "waw" in config.json modules. Put the DeepL key in server.json as deepl. Build new routes here, with a guard, so anonymous callers cannot spend the key.

**Includes:**

- Loaded in it.webart.work and waw-default, but it does not serve working routes.
- With a deepl key it runs a test translation on every start, which spends API quota.
- The WebArtWork/waw-translate repository holds a different, older router; the versions are not in step.

**API:**

| Member | What it does |
|---|---|
| `waw.Translate` | The Mongoose model of cached translations. |
| `translate(target_lang, text, apiKey)` | The DeepL helper in util.js. |

**Example:**

```js
const { translate } = require("./util");

const es = await translate("ES", "Hello, how are you?", waw.config.deepl);
```

**Install:**

waw add waw-translate

Requirements:

- MongoDB
- A DeepL API key, for real translations

### waw-cloudflare

Files on Cloudflare R2: presigned browser uploads, server base64 uploads, public or signed URLs, deletion and a CLI.

| | |
|---|---|
| npm | not on npm |
| Status | released |
| Depends on | [`waw-sem`](#waw-sem), [`waw-user`](#waw-user) |
| Used by | nothing in the framework |
| Repository | https://github.com/WebArtWork/waw-cloudflare |
| Page | https://api.itkamianets.com/packages/waw-cloudflare |

**Purpose.** APIs that store images and documents use waw-cloudflare instead of writing to disk. A browser asks for an upload intent and sends the file straight to R2; server code calls waw.base64ToUrl to store generated files and get a URL back. Keys follow <container>/<fileId>/<variant>, and deleting a file removes its whole prefix.

**Usage.** Not on npm: copy it with waw add waw-cloudflare or list "cloudflare": "waw" in config.json modules. Put the cloudflare block (account, bucket, keys, public URL, limits) in server.json; without it the module does nothing. Save the returned publicUrl or key in your own collection: upload records live only in memory.

**Includes:**

- Runs in it.webart.work and ships in waw-default as server/cloudflare; the repository is current.
- The asset module of it.webart.work stores AI-generated images through it.

**API:**

| Member | What it does |
|---|---|
| `POST /api/cloudflare/upload-intent` | Returns an id, a key and a presigned uploadUrl for a direct PUT. |
| `POST /api/cloudflare/confirm` | Marks an upload as done. |
| `POST /api/cloudflare/upload-base64` | Uploads a base64 file from the request body. |
| `GET /api/cloudflare/:id/url` | The public or signed URL of a file uploaded since the last restart. |
| `DELETE /api/cloudflare/:id` | Deletes the file's whole prefix. |
| `waw.base64ToUrl(base64, container, options)` | Stores a file from server code and returns its URL. |

**Example:**

```js
// server code
const url = await waw.base64ToUrl(base64String, "openai", { name: "logo.png", mime: "image/png" });

// terminal
waw cloudflare upload general default ./default.jpg
waw cloudflare list general
```

**Install:**

waw add waw-cloudflare

Requirements:

- A Cloudflare R2 bucket and an API token
- waw-user, for signed-in uploaders

### waw-telegram

A Telegram bot (grammY) and a contact route that forwards site messages to the right Telegram chat.

| | |
|---|---|
| npm | not on npm |
| Status | released |
| Depends on | [`waw-sem`](#waw-sem) |
| Used by | nothing in the framework |
| Repository | https://github.com/WebArtWork/waw-telegram |
| Page | https://api.itkamianets.com/packages/waw-telegram |

**Purpose.** Websites post a short message, such as a contact form or an order alert, and the API sends it to Telegram. The message goes to the chat id the caller sends, or to the channel a company registered, so each site's messages reach its owner. Sending the text id to the bot replies with that chat's id.

**Usage.** Not on npm: copy it with waw add waw-telegram (it ships in waw-default). Put the bot token in server.json as telegram; without it the module does nothing. Sites call POST /api/telegram/contact with a message and either a chat id or a company slug.

**Includes:**

- Runs in it.webart.work and ships in waw-default as server/telegram.
- The WebArtWork/waw-telegram repository holds a 2022 notifier on slimbot; the grammY version lives only in those projects.

**API:**

| Member | What it does |
|---|---|
| `POST /api/telegram/contact` | Sends message to the chat id, or to the channel of the company slug. |
| `/api/telegramchannel/*` | Generated CRUD for company channels. |

**Example:**

```js
await fetch("https://api.example.com/api/telegram/contact", {
	method: "POST",
	headers: { "Content-Type": "application/json" },
	body: JSON.stringify({ slug: "my-company", message: "New request from the site" }),
});
```

**Install:**

waw add waw-telegram

Requirements:

- A Telegram bot token from BotFather
- A Company model with a slug, for messages addressed by company
