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

jcs-middleware

v0.1.7

Published

Jade, CoffeeScript, Stylus middleware for Express.js

Downloads

26

Readme

                  ____._________   _________                   
                 |    |\_   ___ \ /   _____/                   
                 |    |/    \  \/ \_____  \                    
             /\__|    |\     \____/        \                   
             \________| \______  /_______  /                   
                               \/        \/                    
        .__    .___  .___.__                                       
  _____ |__| __| _/__| _/|  |   ______  _  _______ _______   ____  
 /     \|  |/ __ |/ __ | |  | _/ __ \ \/ \/ /\__  \\_  __ \_/ __ \ 
|  Y Y  \  / /_/ / /_/ | |  |_\  ___/\     /  / __ \|  | \/\  ___/ 
|__|_|  /__\____ \____ | |____/\___  >\/\_/  (____  /__|    \___  >
      \/        \/    \/           \/             \/            \/ 

jcs-middleware

Jade, CoffeeScript, Stylus middleware for Express.js

Installation

Use npm to install jcs-middleware:

npm install jcs-middleware

Usage

In Express app.js

app.use('/', require('jsc-middleware')(options));
app.use('/', express.static(path.join(__dirname, 'public')));

WARNING: jcs middleware MUST go BEFORE static middleware, because it does not render output directly and output to express, instead it depends on static middleware to render the compiled js/css/html files.

Options:

Global options:

 debug          Output debugging information.
 compress       Uglify the output, all of them.
 force          Force compile every time.
 staticRoot     The root directory of the static files.

Coffee-script options:

 coffeeSrc      Source directory used to find .coffee files.
 coffeeDst      Destination directory where the .js files are stored.
 bare           Compile JavaScript without the top-level function safty
                wrapper.
 encodeSrc      Encode CoffeeScript source file as base64 comment in
                compiled JavaScript.

Stylus options:

 stylusSrc      Source directory used to find .styl files.
 stylusDst      Destination directory where the .css files are stored.

Less options:

 lessSrc        Source directory used to find .less files.
 lessDst        Destination directory where the .css files are stored.
 lessPaths      Search paths for @import directives

Jade options:

 jadeSrc        Source directory used to find .jade files.
 jadeDst        Destination directory where the .js files are stored.
 jadeStatics    Hash map used to generate jade pages.

Ejs options:

 ejsSrc        Source directory used to find .ejs files.
 ejsDst        Destination directory where the .js files are stored.
 ejsStatics    Hash map used to generate ejs pages.

If any of the xxxSrc options is ommit, that feature will be turned off.

File Path

Say you have a express website at

http://yourdomain.com/yourapp

Which is located in your server's directory:

/path/to/yourapp

In this app, you store all the static files in public directory, which means, all access to

http://yourdomain.com/yourapp/XXX

goes to

/path/to/yourapp/public/XXX

Then, you have folder for stylus source files,

/path/to/yourapp/stylus

and you want put the generated css files be put into directory:

/path/to/yourapp/public/css

So that anyone can access those css files from url

http://yourdomain.com/yourapp/css/*.css

In this scenario:

  • urlBase is /yourapp
  • staticRoot is /path/to/yourapp/public
  • stylusSrc is /path/to/yourapp/stylus
  • stylusDst is /path/to/yourapp/public/css

for example:

+-- path
   +-- to
      +-- yourapp
         +-- public (staticRoot)
         |  +-- ...
         |  +-- css (stylusDst)
         |     +-- ...
         |     +-- XXX.css   <--------+
         |                            |
         +-- stylus (stylusSrc)       | compile to
            +-- ...                   |
            +-- XXX.styl      --------+

The same with coffee and jade options.

Order of Languages

If source paths of different languages are pointing to the same directory, the following order will be used:

  • stylus > less
  • jade > ejs

Generator

NOTE: Templates that will be generated are out dated, and will be updated soon.

jcs-middleware also comes with a command line tool to generate web application from template; just like express-generator.

To use this generator, you may need to install a copy of jcs-middleware globally:

npm install -g jcs-middleware

##Usage:

Usage: jcs [options] [dir]

Options:

  -h, --help             output usage information
  -V, --version          output the version number
  -f, --force            Force copy template files.
  -n, --name             The name of the web application, default is
                         folder name.
  -t, --template <path>  The template directory, can be ommitted. 

License

MIT (http://www.opensource.org/licenses/mit-license.php)