# katalyst

> Full-stack, highly-scalable web frameworks, based on koa

Latest version **0.0.2** (published 2015-08-18) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2015-08-18 |
| First published | 2015-08-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 10 |
| Known vulnerabilities | 0 (+22 in 4 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | RobinQu |
| Maintainers | robinqu |
| Keywords | Web, frameworks |

## Links

- npm: https://www.npmjs.com/package/katalyst
- Repository: https://github.com/RobinQu/katalyst
- Issues: https://github.com/RobinQu/katalyst/issues
- npm.io page: https://npm.io/package/katalyst

## Dependencies (10)

- [glob](https://npm.io/package/glob.md) ~5.0.14
- [mysql](https://npm.io/package/mysql.md) ~2.8.0
- [catlog](https://npm.io/package/catlog.md) ^1.0.0
- [lodash](https://npm.io/package/lodash.md) ~3.10.1
- [bluebird](https://npm.io/package/bluebird.md) ~2.9.34
- [nunjucks](https://npm.io/package/nunjucks.md) ~1.3.4
- [sequelize](https://npm.io/package/sequelize.md) ~3.5.1
- [koa-router](https://npm.io/package/koa-router.md) ~5.1.2
- [koa-nunjucks](https://npm.io/package/koa-nunjucks.md) 0.0.2
- [koa-app-party](https://npm.io/package/koa-app-party.md) ~0.1.4

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 0.0.2 (latest) — 2015-08-18
- 0.0.1 — 2015-08-16

## README

# katalyst

[![Build Status](https://travis-ci.org/RobinQu/katalyst.svg)](https://travis-ci.org/RobinQu/katalyst)


Fullstack, highly scalable web frameworks, based on koa.

## Usage

`Kt.Application` is a subclass of `Container` from [RobinQu/koa-app-party](https://github.com/RobinQu/koa-app-party).

```
var Kt = require('katalyst');
var App = Kt.Application.design('myapp', __dirname, function(ns) {
  //setup namespace, mount subapps, etc
});
```

### Exporting objects

`katalyst` introduces the notion of home root. Modules or objects can be accessed by `app.require` method.

Define an object in `object.js`:

```
// object.js
module.exports = funciton(app) {

};
```

Require this object using:

```
//object is the extension name of
app.require('object')
```

### Katalyst applications

#### Project layout

A `katalyst` application should have its own project structure. While it's possible to build a very large web application using `katalyst`, elastic nature of `katalyst` make it easy to setup lightweight applications swiftly.

Folder structure for a very simple app:

```
|____index.js
|____lib
| |____app.js
| |____controller
| | |____home.js
| | |____post.js
| |____extension
| | |____relation.js
| |____middleware
| | |____auth.js
| | |____view_model.js
| |____model
| | |____post.js
| | |____user.js
| |____router
| | |____home.js
| | |____post.js
| |____service
| | |____post.js
| | |____user.js
| |____util
| | |____logger.js
| |____view
| | |____home
| | | |____login.tpl
| | | |____register.tpl
| | |____layout
| | | |____default.tpl
| | |____post
| | | |_____post.tpl
| | | |____edit.tpl
| | | |____list.tpl
| | | |____new.tpl
| | | |____show.tpl
|____package.json
|____test
| |____functional
| | |____user_test.coffee
| |____test_helper.coffee
```

Like most MVC applications, it is made up with models, controllers, and views. `katalyst` introduces many new ingredients to the internal architecture that aims to decouple reusable components, like `extension` and `middleware`.

A even more simple app may have a minmal structure like this:

```
|____lib
| |____app.js
| |____extension
| | |____generate.js
|____package.json

```

Like racks in ruby, `Kt.Application` are mountable components. So a large application can be made up with a number of sub-apps which have project structures of there own.

For example:

```
|____index.js
|____lib
| |____app
| | |____repo
| | | |____index.js
| | |____web
| | | |____controller
| | | | |____repo.js
| | | |____index.js
| | | |____router
| | | | |____repo.js
| | | |____view
| | | | |____repo
| | | | | |____list.tpl
| |____index.js
|____package.json
```

This application has two sub-apps, each of which focus on its own isolated features.


#### Extensions

A Extension is a larger component than middleware. In fact, it's often comprised of setup of multiple middlewares.

* Extensions can be async functions that returns a promise
* Export the extensions just like other objects in the project
* Extensions are *automattically* loaded during the bootstrap phase

```
module.exports = function(app) {
  var ns = app.ns();
  var options = ns.get('options');
  var conn = require('mysql').connect(options.mysql);
  ns.set('conn', conn);
  app.use(function *() {
    doSomethingWithMysql(this.ns.get('conn'));
  });
};
```

#### Namespace

Namespace is a concept introduced in [RobinQu/koa-app-party](https://github.com/RobinQu/koa-app-party).

Using namespace across multiple calls, including async ones, can be handy for

* Sharing or isolating objects
* Removing dependencies
* Improving code style

There are some pitfalls using a namespace, which will be detailed latter. However, the golden rule of writing applications with `katalyst` is always inject your objects into a namespace if possible instead of storing on the `app` or `app.context`.

## Examples

* [reader](samples/reader) A simple blog server to serve posts
* [giterver](samples/gitserver) A private git server over HTTP

## TODO

* More test cases
* Docs

## License

MIT

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