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

mvcfun

v0.4.5

Published

MVC based web server framework

Downloads

8

Readme

MVCfun

MVCfun is an model-view-controller based web server framework.

Register controllers to ressource paths. You may use regular expressions for this to register a controller to a bunch of paths at once.

This project is under high development and new features pop out every week. Contributers are very welcome.

Quick example

var mvcfun     = require('mvcfun'),
    controller = mvcfun.controller,
    regexp     = mvcfun.regexp;

var server = (new mvcfun.http.Server())
    .listen(8080)
    .on('error', function(err) {
        console.log(err.stack);
        server.close(function() { process.exit(1) });
    });

server.addController(new controller.Static(regexp.files));
server.addController(new controller.Forbidden(regexp.directories));

This creates an http server listening on port 8080. It serves all static files located relatively to the default directory 'htdocs' and forbid any access to directories.

Why MVC

The model-view-controller pattern is well known in web development. Using this pattern makes code more readable and maintable without loosing performance.

Key features

- MVC based developing the cool way
- Easy controller handling
- Maintainable code
- Increadibly fast
- RESTFul developing possible in same framework
- Swig template engine included
- Multi-language page support (including SEO features)
- High unit test coverage

Custom Controller

The main idea of MVCFun is to design your web project based on model, views and controllers. The key part are the controllers, because they connect the models with the views.

Therefore it's absolutely necessary to be able to create custom controllers very easily. This is one main feature of MVCFun.

// The Hello World

var mvcfun     = require('mvcfun'),
    controller = mvcfun.controller,
    util       = require('util'),
    regexp     = mvcfun.regexp;

var HelloWorldController = function(filename) {
    controller.Base.call(this, filename);
};
util.inherits(HelloWorldController, controller.Base);

HelloWorldController.prototype.run = function(resp, path) {
    this.responseManager.writeText(resp,'Hello World!');
};

var server = (new mvcfun.http.Server()).listen(8080);
server.addController(new HelloWorldController('/helloworld'));

If you run this example and surfs at "localhost:8080/helloworld" you will read "Hello World!" as plain text response.

For sure, the controllers should be organized in seperate files (one per controller). The controller can easily require any class to connect to them (models) and use any kind of template engine to create the view. There is build in swig support.

Installation

Fast way using npm

The most simple way to install MVCfun is using npm:

npm install mvcfun

There you will get the last stable release containing all features.

Custom installation

MVCfun is organized in branches. Each branch has its own set of features. For instance the swig branch contains swig binding and a swig base controller.

If you want the naked framework, checkout the minimal branch. You may merge as many of the feature branches together as you want.

The master branch contains all features merged together and the versions published in npm come from the master branch.