Serving YUI from express as middleware

npm install express-yui-serve
7 downloads in the last month

Express Middleware for serving YUI

Middleware for express that allows you to serve YUI locally from the installed node package.


npm i express express-yui-serve


Require the express-yui-serve package and give it the app and the route to attach to. In the below example, app is my express app and yui3 is my route.

This wil create the following routes on your app:


The seed route is where you point your JS to load a pre-configured YUI seed file. This route also supports the filter parameter:

<script src="/yui3/seed"></script>
<script src="/yui3/seed?filter=raw"></script>
<script src="/yui3/seed?filter=debug"></script>

Now you need to expose these routes:

var app = require('express').createServer(),
    YUIify = require('express-yui-serve');

//Routes are create for you now..


#!/usr/bin/env node

var app = require('express').createServer(),
    fs = require('fs'),
    YUIify = require('express-yui-serve');

YUIify(app, 'yui3');

app.get('/', function(req, res) {
    res.send(fs.readFileSync('./index.html', 'utf8'));

<!doctype html>

<script src="/yui3/seed?filter=debug"></script>
YUI().use('node', function(Y) {'body').setStyle('backgroundColor', 'green');
npm loves you