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

nodebuilder

v0.9.4

Published

Node Express Project Planner

Downloads

2

Readme

nodebuilder

Node package for rapid ExpressJS routing buildout

Use this package when first building out the routes for your ExpressJS app. At the moment this package will create controller files that contain routes for GET and POST, but not PUSH and DELETE, so it's not yet suitable for API development.

When loaded into your app.js it will do the following:

  • On any "missing" route (404) it will display a form allowing you to describe the route and define any of its exits, including the exit method ("global", "get", "post" or "redirect").
  • Once submitted it will create a controller file if needed, then create a stubbed route.
  • If the defined exits are of type "global" it will create links in a global nav file that is included in every page.
  • If the defined exits are of type "get" it will create a view file with links to those exits.
  • If the defined exits are of type "post" it will create a view file with a form that submits to that exit.
  • If the defined exit is of type "redirect", it will leave out the view file and write a "resp.redirect()" into the route instead.

It works with some basic assumptions:

  • It will create controllers and collect routes based on the first token of the URI, so "/products/search" and "/products/:id" would both be methods in the "products" controller. Therefore, the routes you describe and the exits you define have to have at least 2 tokens in their URIs.
  • It will create .pug view files, so you need to have the "pug" package installed in your project.

This package works best when you can automatically load in your changes, so I've found that using an autoloader for controller files, along with a process monitoring for file changes, really speeds up the development process when using this package. Having these two automation helpers allows the developer to point their browser to a URI they'd like to define, then just click on links and submit forms as they author them in order to completely define the project skeleton.

Here's a sample app.js file that illustrates these ideas:

app.js:

// dependencies
var express      = require('express'),
	path         = require('path'),
	app          = express(),
	fs           = require('fs'),
	session      = require('express-session'),
	bodyParser   = require('body-parser'),
	pug          = require('pug');

// environment variables
app.set('view engine', 'pug');
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());

// dynamically include routes (Controller)
fs.readdirSync('./controllers').forEach(function (file) {
	if(file.substr(-3) == '.js') {
		var fc = file.replace('.js', '');
		app.use('/'+fc, require('./controllers/' + file));
	}
});

// nodebuilder will handle any undefined routes
app.use(require('nodebuilder'));

app.listen(process.env.PORT, function(){
  console.log('Express server listening on port ' + process.env.PORT);
});

Automatic Reloading

For monitoring changes to the app and automatically reloading, I found nodemon worked pretty well:

$ sudo npm install -g nodemon
$ nodemon app.js

Thanks for using nodebuilder!

This project was created to help you save development time and money. Did it?

Donate

About the author

Mike Ritchie has been developing web applications for over a decade, and is largely known for the "FuseBuilder" app, which allowed PHP and ColdFusion developers to rapidly describe their own web applications using the "Fusebox" framework and methodology. FuseBuilder was quite a bit more advanced in that it not only created a wireframe of the developer's app, it allowed the developer to actually create working forms and layouts in the view, along with model files with working SQL and controllers with actual business logic. Nodebuilder is an offshoot of this concept applied to the Node/Express paradym. It's hoped that one day Nodebuilder will have much of the same power.