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

katalyst

v0.0.2

Published

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

Downloads

13

Readme

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