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

firewire

v1.0.5

Published

firewire | a modular ecosystem for building firebase apps in express.

Downloads

1

Readme

firewire is a modular ecosystem to help build firebase apps in express.
Since it's all underpinned by express, you can still use any other middleware you want.

Create your express app

Don't have express generator, get it - $ npm install express-generator -g

Create an express app via express generorater. Note that we use jade templates to pass firewire data to the front end.

$ express myapp

Install dependancies

$ cd myapp
$ npm install

Add a public node_modules in express

This will allow you to install firewire public modules. This is a good thing.

$ cd public
$ npm init

follow the prompts to create a blank app, which will create a node_modules folder when you install something into it

firewire

If you just added your public node_modules, then you'll need to get back to the root of your app!

Once you're back at the root of your app - install firewire

$ npm install firewire --save

Configure firewire

// index.js in express...
    
var express = require('express');
var router = express.Router();
var firewire = require("firewire");

// Use your own firebase url!!!
firewire.load = {
	url : "https://your-firebase-project.firebaseio.com/"
};

Now you can use firewire in place of res.render to dynamically load a template and inject firebase data into it.

Like this...

router.get('/:page/id/:instance', function(req, res, next) {
	firewire.wire(req,res,firewire.load,[
		{"ids/:instance" : "home"},
		{"pages/:page" : "page"}
	]);
});

Using the above example, if you goto localhost:3000/admin/id/123
firewire will use admin.jade from your views folder
firewire will then expose fw.home and fw.page to the jade template.
fw.home will be populated with data from https://your-firebase-project.firebaseio.com/ids/123
fw.page will be populated with data from https://your-firebase-project.firebaseio.com/pages/admin

Use that data in your jade templates #{fw.home} ... #{fw.page}

Template selection

  • Using :page tells firewire to use that jade template
  • If you don't wan't to use :page, you can still tell firewire what template you want to use with req.params.page = "page-name";

Eg. This will route to admin.jade

/*Dynamic Page and Data Loader */
router.get('/admin/:instance', function(req, res, next) {
	req.params.page = "admin";
	firewire.wire(req,res,firewire.load,[
		{"drafts/:instance" : "itemType"}
	]);
});

Static Data

You can also parse through static (non-firebase) data with firewire.load.static

router.get('/admin/:instance', function(req, res, next) {
	req.params.page = "admin";
	firewire.load.static ={'title' : "some static data"};
	firewire.wire(req,res,firewire.load,[
		{"drafts/:instance" : "itemType"}
	]);
});

You can then plug this into a jade template with #{static.title}

Running your app in local

Now if you have the following route set up

router.get('/:page/id/:instance', function(req, res, next) {
	firewire.wire(req,res,firewire.load,[
		{"ids/:instance" : "home"},
		{"pages/:page" : "page"}
	]);
});

And you've added data in firebase at:

ids
    123 : "Some data"
pages
    admin : "some data"

And you have a template called admin.jade in your views folder using #{fw.home} and / or #{fw.page}

And you run your app...

Use something like nodemon so your app automatically restarts on code changes

$ npm install nodemon -g

To run...

$ nodemon

Goto your browser at localhost:3000/admin/id/123 and your app should automatically route to admin.jade and plug in the firebase data.

Public Modules

Providing that you've set up your public node_modules (explained near top of page) then just...

$ cd public

then just $npm install ... whatever public module you want.

Check out...