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

Monorail.js

v1.0.1

Published

Ultra lightweight MVC for Node.js

Downloads

2

Readme

endorse

Monorail.js - Ultra lightweight MVC Framework for Node.js

TLDR; Monorail.js will never force you, and uses only what you need. Monorail.js will never force you to install anything not needed for your project. The goal is to use what you need. Anything other than creating a project will always be optional. Scaffold models in seconds

Monorail.js Logo

npm install Monorail.js

Or start a project right now with Railing.sh

./railing.sh Project_Name

No configuration required. Zero Touch Configuration to get you up and running.

$ ./monorail.js new project example
Creating Project example
Making directory example
Making directory example/static
Making directory example/static/img
Making directory example/static/js
Making directory example/static/css
Making directory example/themes
Making directory example/themes/classic
Making directory example/themes/classic/img
Making directory example/themes/classic/js
Making directory example/themes/classic/css
Making directory example/models
Making directory example/views
Making file example/monorail.project
Making file example/routes.js
Making file example/redis.config
Making file example/themes/classic/classic.html
Making file example/themes/classic/css/classic.css
Copying libs...

$ cd example

$ cat monorail.project
name : example
theme : classic
express_port : 8123

$ ../monorail.js start server
Starting Redis...
Redis Running on Process 3822
Starting Express
Express Running on Process 3825

Congratulations. You're DONE!

Example

Lets install Mootools and RightJS

[user@machine tmp]$ ls 
Example  README.md  lib  monorail.js  monorail.js-small.png  monorail.js.png  package.json

[user@machine tmp]$ cd Example/

[user@machine Example]$ ../monorail.js
install [mootools | rightjs | jquery | dojo | prototype ] ; Install JS Framework in this project
start server ; Start project Redis & Express server
new project [project_name] ; Creates project
new page [page_name] ; Creates new project page

[user@machine Example]$ ../monorail.js install mootools
[user@machine Example]$ ../monorail.js install rightjs 
[user@machine Example]$ tree static/
static/
|-- css
|-- img
`-- js
	  |-- mootools-core-1.4.5-full-compat.js
	  `-- right-2.3.1.js

3 directories, 2 files

Make a new page

$ ../monorail.js new page user

Lets view our user view

$ cat views/user.xml 
<#CODE#>html_body = 'This code block takes 100% node.js code.';</#CODE#>

Change it to this

<#CODE#>html_body = 'Viewing profile of '+username;</#CODE#>

Lets view our user model

$ cat models/user.js 

var nohm = require('../lib/nohm').Nohm;
var redis = require('../lib/nohm/node_modules/redis');
var client = redis.createClient();

nohm.setClient(client);
nohm.model('user',{});

Lets add a controller to the bottom of route.js

app.get('/user/:name', function(req, res) {
  user = req.params.name;
  view = loadView('user',{ username: user });
  page = railed('Viewing User - '+user, view);
  res.send(page);
});

app.listen(express_port);
  

Lets start the server up and point our browser to http://localhost:8123/user/any_name_here

$ ../monorail.js start server
Starting Redis...
Redis Running on Process 3822
Starting Express
Express Running on Process 3825

There's more examples in the wiki :)

Scaffolding in Node.js

	[user@machine Exampel]$ ../monorial.js generate blogpost title:string pubDate:timestamp
	[user@machine Example]$ cat models/blogpost.js
	var nohm = require('../lib/nohm').Nohm;
	var redis = require('../lib/nohm/node_modules/redis');
	var client = redis.createClient();

	nohm.setClient(client);
	nohm.model('blogpost', {
		 idGenerator: 'increment',
		 properties: {
			  title: {
			     type: 'string',
			     validations: ['notEmpty']
			  },
			  pubDate: {
			     type: 'timestamp',
			     defaultValue: new Date()
			  }
		 }
	});

What's new in version 1

	[user@machine Monorail.js]$ ./monorail.js new project Example
	Creating Project Example
	Making directory Example
	Making directory Example/static
	Making directory Example/static/img
	Making directory Example/static/js
	Making directory Example/static/css
	Making directory Example/themes
	Making directory Example/themes/classic
	Making directory Example/themes/classic/img
	Making directory Example/themes/classic/js
	Making directory Example/themes/classic/css
	Making directory Example/models
	Making directory Example/views
	Making file Example/monorail.project
	Making file Example/routes.js
	Making file Example/redis.config
	Making file Example/themes/classic/classic.html
	Making file Example/themes/classic/css/classic.css
	Copying libs...
	[user@machine Monorail.js]$ cd Example/
	[user@machine Example]$ ls
	lib  models  monorail.project  redis.config  routes.js  static  themes  views

	[user@machine Example]$ ../monorail.js 
	hashtree 
	|_ Return a hash tree of the current project

	install [mootools | rightjs | jquery | dojo | prototype ] 
	|_ Install JS Framework in this project

	new model [model_name] 
	|_ Creates model w/  no view

	new page [page_name] 
	|_ Creates new project page

	new project [project_name] 
	|_ Creates project

	new view [view_name] 
	|_ Creates view w/ no model

	reset project 
	|_ Removes files from static, models, and views

	snapshot [ create | clean ] 
	|_ backup your models, views, and routes

	start server 
	|_ Start project Redis & Express server

	summary 
	|_ Returns a project summary

	update 
	|_ Download the latest Monorail.js (script only)

	[user@machine Example]$ ../monorail.js snapshot create
	Saved
	[user@machine Example]$ ls -l snapshots/
	total 16
	-rw-r--r-- 1 user users 3371 Mar 29 00:58 2012.03.28T15.58.43.524Z.zip
	-rw-r--r-- 1 user users 3371 Mar 29 00:58 2012.03.28T15.58.45.467Z.zip
	-rw-r--r-- 1 user users 3371 Mar 29 00:58 2012.03.28T15.58.46.133Z.zip
	-rw-r--r-- 1 user users 3371 Mar 29 00:58 2012.03.28T15.58.46.829Z.zip
	[user@machine Example]$ ../monorail.js snapshot clean

	WARNING: All snapshots will be DELETED!
	Type continue to continue: continue
	Snapshots deleted.

	[user@machine Example]$ ls -l snapshots/
	total 0
	
	[user@machine Example]$ ../monorail.js new page home
	[user@machine Example]$ ../monorail.js new view about
	[user@machine Example]$ ../monorail.js new model user
	[user@machine Example]$ ../monorail.js summary 
	views: 2
	models: 2
	themes: 1
	
	[user@machine Example]$ ../monorail.js hashtree
	./views/about.xml: 72c05ce377c77bf828f19290f6a984f3133cabbb
	./views/home.xml: 6a1f00f99f017f79d7f683e080f7ebdfa5783211
	./models/user.js: be9f2b1e2cf13d2c7ecdb65104b110593718600f
	./models/home.js: 5bd607fa91b475405f49ba6314552c0ede345e99
	./routes.js: cf579e914e61a235aab5ad25fc72d4052c42fa3d
	./redis.config: c220348239ca26abdb54651cd7f340b2a98f0e83
	./monorail.project: 958f07662d6ca27b36d744703094ed8d1e761341
	
	[user@machine Example]$ ../monorail.js reset project

	WARNING: All files in the views, models, and static folders will be DELETED!
	Type the word continue to continue: continue
	Cleaning up ./views/about.xml...
	Cleaning up ./views/home.xml...
	Cleaning up ./models/home.js...
	Cleaning up ./models/user.js...
	Your project has been reset :)
	
	[user@machine Example]$ ../monorail.js update
	Saving to new_monorail.js
	
	[user@machine Example]$ du -hs new_monorail.js 
	888K	new_monorail.js

Documentation

Monorail.js

https://github.com/runexec/Monorail.js/wiki

JS Frameworks

http://docs.jquery.com/Main_Page http://mootools.net/docs/core http://rightjs.org/docs http://api.prototypejs.org/ http://dojotoolkit.org/documentation/

Redis ORM

http://maritz.github.com/nohm/

Redis

https://github.com/mranney/node_redis

Express Routing, Cookies, and Sessions

http://expressjs.com/guide.html#session-support http://expressjs.com/guide.html#http-methods http://expressjs.com/guide.html#routing http://expressjs.com/guide.html#passing-route%20control http://expressjs.com/guide.html#route-middleware http://expressjs.com/guide.html#route-param%20pre-conditions

Compatibility

It has currently only been tested on unix, but should work on windows with little or no changes.

Built and tested with node v0.6.13 nohm ORM vs 0.9.0 express 2.58

TODO

Add easy html.escape/html.unescape functions Create examples for the new switches below Add scaffolding Add update Monorail.js switch Add reset project switch Add create snapshot switch Add clear snapshots switch Add build hash tree switch Add create model (independent of view) switch Add create view (independent of model) switch Add project summary switch (MAYBE) Add recover snapshot switch  Never (MAYBE) Add compare snapshot switch  Never Theme/Template documentation More Wiki-Examples coming very very soon. Heavy Bug Testing

License

MIT License Copyright (c) 2012 Ryan Kelker and individual contributors.