Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

katalyst

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

katalyst

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

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

katalyst

Build Status

Fullstack, highly scalable web frameworks, based on koa.

Usage

Kt.Application is a subclass of Container from 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.

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 A simple blog server to serve posts
  • giterver A private git server over HTTP

TODO

  • More test cases
  • Docs

License

MIT

Keywords

FAQs

Package last updated on 18 Aug 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc