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

express-all-inclusive

v1.0.4

Published

Express Middleware for lazy people

Downloads

7

Readme

All-Inclusiv

Experimental Express Middleware for Mobile HTML5 Apps to be used by very lazy people.

#Usage

DO NOT USE IT YET

Install module

npm install express-all-inclusive --save

In app:

var static = require('express-all-inclusive');

Folders

Your mobile app might have multiple endpoints: project, each inside a single folder, e.g.

  • www
  • landing
  • adm

Registering a folder to serve its content:

static.addFolder('www', { //options object
  version: 'v1.0.0'
});

The folder is now available via static.www

Options

version: will replace <!--version--> in appcache and html files, e.g.:

CACHE MANIFEST
# Generated: <!--version--> 

becomes

CACHE MANIFEST
# Generated: v1.0.0 

To deploy a new app version, increase the app version.

Files

So far there is build in support for html, js, css and appcache files.

Simple serve

app.get('/app.js', static.static.serve());

This will server the /static/app.js file.

Advanced serve

If you want to server files only in special cases, pass req and res parameters on the the serve method.

app.get('/cache.appcache', function(req, res){
  if (false){
    res.send('');
  } else {
    static.static.serve(req, res, {});
  }
});

Options

fileName

By default

app.get('/test', static.static.serve());

would serve the text.html file. You can change this behaviour by either passing the fileName directly or as object property.

app.get('/test', static.static.serve('testPage.html'));
//equals
app.get('/test', static.static.serve({fileName:'testPage.html'}))

include

For mobile applications it is nice to save some requests, there for you can merge files.

static.static.serve(req, res, {
  include: ['app.js', 'style.css']
});

This code would replace in production inside index.html

<script src="app.js"></script> with <script>//Minified JS code</script>

and

<link href="style.css" rel="stylesheet"> with <style>/* Minified CSS code*/</style>

Bonus features

Files are served differently on localhost and in production. In production

  • js files are ng-annotated and uglyfied
  • css files are minified
  • html files are minified
  • js and css files and be merged into html files

On localhost

  • appcache files are not served

You can emulate production on localhost by added the ?force=true parameter to all requests.

Auto-Reload

Since we are so lazy, auto-reload is build in for html files.

To enable auto-reload add as last statement in your Express app:

if (localhost){
  var port = app.get('port') + 1;
  static.watch();
}

Add to every html file to be watched:

<!--reload-->

By default, all files inside the registered folders are watched. You can register files via static.addFolder. You can specify the watched folders by passing an array of folders.

static.watch(['adm', 'static']);