JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3664
  • Score
    100M100P100Q114367F

Easily share data between your server-side and browserify modules.

Package Exports

  • sharify

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sharify) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

sharify

Easily share data between your server-side and browserify modules.

Example

Given an express app with jade.

app.js

var sharify = require('sharify');
var app = require('express')();
sharify(process.env).pick('API_URL').add(app);

index.jade

html
  body
    #scripts
      //- Make sure this is above your other scripts
      != sharify.script
      script( src='/jquery.js' )
      script( src='/bundle.js' )

client.js

// Browserify module
var sd = require('sharify').data;
var $ = require('jquery');
$(function() {
  $.ajax({ url: sd.API_URL + '/artwork/andy-warhol-skull' });
});

API

sharify(obj)

Includes a hash to be shared between modules.

sharify.pick([keys...])

Whitelists keys to conveniently exclude sensitive data.

sharify.add(app)

Adds sharify to an express app's locals and generates a script tag which can be accessed via sharify.script.

Contributing

Please fork the project and submit a pull request with tests. Install node modules npm install and run tests with make test

License

MIT