bundle up your javascripts: a minimal HTTP API for browserify
npm install snuggie
snuggie is an http server
var snuggie = require('snuggie')
snuggie(httpPort, onListeningCallback)or
var snuggieHandler = require('snuggie').handler
require('http').createServer(snuggieHandler).listen(8000)
or
var snuggie = require('snuggie').handler
require('http').createServer(function(req, res) {
snuggie(req, function(err, bundle) {})
}).listen(8000)
first you must make a PUT/POST request to snuggie where your request upload body contains an ascii a javascript program (no multipart form uploads allowed)
then snuggie will use browserify to bundle your program and send you back a bundle. any node module available to your node server will be available to snuggie
e.g. :
var request = require('request')
request.post({url: "http://snuggieserver:8000", body: "var foo = require('util')", json: true}).pipe(process.stdout)the http response will be either:
{"bundle": "// browserified bundle output contents"}or
{"error": "// syntaxError or moduleMissing", "message": "// a hopefully helpful error message"}you can also just pass a function string and a callback:
snuggie.bundle(funcString, function(err, bundle) {})npm test runs the server side tests. to test that CORS works okay run node browser-test.js and then open up localhost:8080 in a browser
BSD