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

rendr-app-template

v0.2.2

Published

The purpose of this little app is to demonstrate one way of using Rendr to build a web app that runs on both the client and the server.

Downloads

75

Readme

Rendr App Template

GitHub Browser

The purpose of this little app is to demonstrate one way of using Rendr to build a web app that runs on both the client and the server.

Running the example

First, make sure to have Node >= 0.8.0 installed on your system. Then, clone this repo to a local directory and run npm install to install dependencies:

$ git clone [email protected]:airbnb/rendr-app-template.git
$ cd rendr-app-template
$ npm install

Then, start the web server. It defaults to port 3030. This will also run grunt to compile assets.

$ npm start

> [email protected] start /Users/spike/code/rendr-app-template
> DEBUG=app:* node index.js

Running "handlebars:compile" (handlebars) task
File "app/templates/compiledTemplates.js" created.

Running "bundle" task
Compiled /Users/spike/code/rendr-app-template/public/mergedAssets.js

Running "stylus:compile" (stylus) task
File public/styles.css created.

Done, without errors.

server pid 71878 listening on port 3030 in development mode

Then pull up the app in your web browser:

$ open http://localhost:3030

You can choose a different port by passing the PORT environment variable:

$ PORT=80 npm start

GitHub API rate limit

GitHub rate limits unauthenticated requests to its public API to 60 requests per hour per IP. This should be enough for just playing with the sample app, but if you pull it down and start developing off it you may run up against the rate limit.

If this happens to you, you can supply your GitHub creds for HTTP Basic Auth using the BASIC_AUTH environment variable. Be very, very careful with this! It means you will be typing your GitHub credentials in plain text, which will be saved to your Bash history and may be intercepted by other programs. If you do this, immediately change your password before and afterwards. This should only be necessary if you're developing on the app and need to keep refreshing the page.

$ BASIC_AUTH=githubusername:githubpassword npm start

You've been warned. Your best bet may be to alter the project to read from your favorite RESTful API.

Getting Started With Rendr

This basic Rendr app looks like a hybrid between a standard client-side MVC Backbone.js app and an Express app, with a little Rails convention thrown in.

Check out the directory structure:

|- app/
|--- collections/
|--- controllers/
|--- models/
|--- templates/
|--- views/
|--- app.js
|--- router.js
|--- routes.js
|- assets/
|- config/
|- public/
|- server/

Note: I want to stress that this is just one way to build an app using Rendr. I hope it can evolve to support a number of different app configurations, with the shared premise that the components should be able to run on either side of the wire. For example, the full-on client-side MVC model isn't appropriate for all types of apps. Sometimes it's more appropriate to load HTML fragments over the wire, also known as PJAX. Rendr apps should be able to support this as well.

Routes file

// app/routes.js
module.exports = function(match) {
  match('',                   'home#index');
  match('repos',              'repos#index');
  match('repos/:owner/:name', 'repos#show');
  match('users'       ,       'users#index');
  match('users/:login',       'users#show');
};

Controllers

A controller is a simple JavaScript object, where each property is a controller action. Here is the most simple controller.

// app/controllers/home_controller.js
module.exports = {
  index: function(params, callback) {
    callback(null, 'home_index_view');
  }
};

Views

// app/views/home_index_view.js
var BaseView = require('./base_view');

module.exports = BaseView.extend({});
module.exports.id = 'HomeIndexView';

We set the property indentifier on the view constructor to aid in the view hydration process. More on that later.

If using CoffeeScript, a view constructor's name property is set for you.

# app/views/home_index_view.coffee
BaseView = require('./base_view')

module.exports = class HomeIndexView extends BaseView

console.log(module.exports.name)
 => "HomeIndexView"

The view lifecycle

The view hierarchy

Templates

Asset Bundling

TODO

  • Lazy load repos

License

MIT