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

osmmvc

v2.1.0

Published

A super simple MVC pattern maker for Express.

Downloads

2

Readme

OSMMVC

A super small, super light, routing magic plugin for creating MVC patterns in Node.js with Express.

Usage

Install osmmvc with npm install osmmvc or add it to your package.json depedencies "dependencies": { "osmmvc": "2.0.0" } and call npm install

Add the following lines to your application's main js file. They must fall after any Express configuration. app is the express() function return.

var mvc = require('osmmvc');
mvc.routing(app);

If you need additional pathes outside of the /:controller/:action/para/met/ers pattern you can either declare them above the mvc.routing(app); line or use the additional routing function. For example:

var mvc = require('osmmvc');
mvc.routing(app, function(app) {
	app.get('/some/other/path', function(req, res) {
		// Whatever actions you need.
	});

	// OR if you need to pass off a path to a specific controller function
	mvc.Route("/the/path/:aParameter", "", "get");  /* last argument is a comma separated list of 
	valid HTTP methods.  if blank it defaults to all */
});

Controllers need to be created inside the /controllers/ folder. They must include the osmmvc Controller object. A basic example looks like this:

var osmmvc = require('osmmvc');
var Controller = osmmvc.Controller;

var MainController = new Controller();

MainController.index = function(input, output) {
	output.render({ title: 'The index page!', body: 'Common body stuff' }); // Will render /views/MainController/index passing in a title and body variable.
	// OR if you don't want to use the default view 
	output.render('/this/layout', { title: 'The index page!', body: 'Common body stuff' });
	// OR if you don't need anything at all
	output.render();
}

module.exports = MainController;

The output.render command wraps

You can render a layout through your normal Express renderer using output.render or send information using output.send. Using the render wrapper also passes the controller name, the called action, and the current date to your template. The output object also wraps .redirect and .sendFile.

Response and Request objects can be found in the output.res and this.req variables of the Controller object. Use the response object to do anything you'd normally do in an Express path.

Tutorial Page

OSMstudios Tutorial Page