Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

express-yui

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-yui

Express extension for YUI Applications

  • 0.4.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
27
decreased by-49.06%
Maintainers
1
Weekly downloads
 
Created
Source

Express YUI

Express extension for YUI Applications.

Build Status

Goals & Design

This compontent extends express by adding a new member to the express application thru app.yui. This object is responsible for exposing the yui_config and yui_seed configurations into the view engine. Also, it provides a set of runtime utilities that can be used to customize the YUI config for the client side, creates a Y instance on the server side when needed to provide access to the registered modules on the server side, and provides a set of middleware to expose data into the runtime and the client side.

Installation

Install using npm:

$ npm install express-yui

Features

Features

  • expose yui config per request
  • expose seed files per request
  • provide basic configurations for cdn, debug, and other common conditions
  • provide basic middleware to server static assets from origin server, including combo capabilities built-in.
  • provide basic middleware to expose yui_config and yui_seed into the view engine so they can be used in the templates to boot YUI in the client side.

Other features

  • work with modown-locator to produce a build process by shifting any yui module in the application bundle or any other bundle.
  • provide basic express view engine to rely on views registered at the server side thru the app.yui.use() as compiled templates.

Usage

Extending express functionalities

express-yui is a conventional express extension, which means it will extend the functionalities provided on express by augmenting the express app instance with a new member called yui. At the same time, express-yui provides a set of static methods that you can call directly off the express-yui module, those methods are utility methods and express middleware.

Aside from that, express-yui will try to extend the express peer dependency to augment the app instance automatically everytime you call express() to create a brand new instance. This is useful, and in most cases just enough. Here is an example:

var express = require('express'),
    yui = require('express-yui'),
    app = express();

app.yui.applyConfig({ foo: 'something' });

As you can see in the example above, the yui member is now available for the app, and the only thing you have to keep in mind is the order of the require statements.

But this is not always the case. Sometimes you have a 3rd party module that is requiring express, and even creating the app under the hood, in which case you can just augment an existing express app instance by doing this:

var yui = require('express-yui'),
    express = require('express'),
    app = express();

// calling a yui static method to augment the `express` app instance
yui.augment(app);

app.yui.applyConfig({ foo: 'something' });

Exposing app state into client

TBD

Using yui modules on the server side

TBD

Serving static assets from app origin

app.yui.setCoreFromAppOrigin();
app.yui.registerGroup('foo', 'path/to/foo-1.2.3'); // if you use locator, this is not needed
app.use(yui.static());

With this configuration, a group called foo with version 1.2.3, and yui version 3.10.2, it will produce urls like these:

  • /combo~/yui-3.10.2/yui-base/yui-base-min.js~/foo-1.2.3/bar/bar-min.js~/foo-1.2.3/baz/baz-min.js
  • /yui-3.10.2/yui-base/yui-base-min.js
  • /foo-1.2.3/bar/bar-min.js

Serving static assets from CDN

If you plan to serve the build folder from CDN, then make sure you set that before registering any group, so loader can know about it. Here is the example:

app.yui.setCoreFromCDN();
app.set('yui combo config', {
    comboBase: 'http://mycdn.com/path/to/combo?',
    comboSep: '&',
    maxURLLength: 1024
});
app.set('yui default base', 'http://mycdn.com/path/to/static/{{groupDir}}/');
app.set('yui default root', 'static/{{groupDir}}/');
app.yui.registerGroup('foo', 'path/to/foo-1.2.3'); // if you use locator, this is not needed

in which case you don't need to use yui.static middleware since you are not serving local files.

With this configuration, a group called foo with version 1.2.3 will produce urls like these:

License

This software is free to use under the Yahoo! Inc. BSD license. See the LICENSE file for license text and copyright information.

Contribute

See the CONTRIBUTE file for info.

Keywords

FAQs

Package last updated on 14 Jun 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc