Permalink
Fetching contributors…
Cannot retrieve contributors at this time
161 lines (156 sloc) 6.9 KB
<!doctype html>
<html>
<head>
<title>Browserify-CDN</title>
<link rel="stylesheet" href="style.css">
<script type="text/javascript">
window.onload = function(){
document.getElementById('url-generator').onsubmit = function() {
module = this.elements["module"].value
ver = this.elements["ver"].value
path = "https://wzrd.in/standalone/" + module + "@" + ver
link = document.createElement('a')
link.href = path
link.target = '_blank'
link.click()
return false
}
}
</script>
</head>
<body>
<div id="logo">
<img src="/img/browserify.png">
</div>
<div id="content">
<h1 id="browserify-as-a-service">browserify-as-a-service</h1>
<p><a href="https://travis-ci.org/jfhbrook/wzrd.in"><img src="https://travis-ci.org/jfhbrook/wzrd.in.png?branch=master" alt="Build Status"></a></p>
<h4 id="places">Places</h4>
<ul>
<li><a href="https://github.com/jfhbrook/browserify-cdn">fork me on github</a></li>
<li><a href="http://browserify.org">browserify on the web</a></li>
<li><a href="https://github.com/maxogden/browser-module-sandbox">browser-module-sandbox</a> - helpful for using multi-bundles</li>
<li><a href="http://requirebin.com">requirebin.com</a> - powered by browserify-cdn</li>
<li><a href="http://esnextb.in">esnextb.in</a> - also powered by browserify-cdn</li>
</ul>
<h1 id="quick-start">Quick Start</h1>
<p>Try visiting this link:</p>
<p><a href="/standalone/concat-stream@latest">/standalone/concat-stream@latest</a></p>
<form method="get" id="url-generator"><h3>Or choose a module here:</h3><label>Module:<input type="text" name="module" value="concat-stream" required /></label><label>Version:<input type="text" name="ver" value="latest" required /></label><input type="submit" value="Go!" /></form>
<h2 id="what-just-happened-">What just happened?</h2>
<p>Well, in <em>this</em> case, since someone has visited this link before you,
the file was cached with <a href="https://github.com/rvagg/node-levelup">leveldb</a>.
But if you were to try and grab a bundle that
<em>nobody else has tried to grab before</em>, what would happen is this:</p>
<ul>
<li>The module gets pulled down from <a href="http://npmjs.org">npm</a> and installed</li>
<li>The module gets <a href="http://browserify.org">browserified</a> as a standalone bundle</li>
<li>The module gets sent to you, piping hot</li>
<li>The module gets cached so that you don&#39;t have to wait later on</li>
</ul>
<h1 id="api">API</h1>
<p>There are a few API endpoints:</p>
<h2 id="get-bundle-module">GET /bundle/:module</h2>
<p>Get the latest version of :module.</p>
<h2 id="get-bundle-module-version">GET /bundle/:module@:version</h2>
<p>Get a version of <code>:module</code> which satisfies the given <code>:version</code>
<a href="https://github.com/isaacs/node-semver#ranges">semver range</a>. Defaults to latest.</p>
<h2 id="get-debug-bundle-module">GET /debug-bundle/:module</h2>
<h2 id="get-debug-bundle-module-version">GET /debug-bundle/:module@:version</h2>
<p>The same as the prior two, except with <code>--debug</code> passed to browserify.</p>
<h2 id="get-standalone-module">GET /standalone/:module</h2>
<h2 id="get-standalone-module-version">GET /standalone/:module@:version</h2>
<p>In this case, <code>--standalone</code> is passed to browserify.</p>
<h2 id="get-debug-standalone-module">GET /debug-standalone/:module</h2>
<h2 id="get-debug-standalone-module-version">GET /debug-standalone/:module@:version</h2>
<p>Both <code>--debug</code> and <code>--standalone</code> are passed to browserify!</p>
<h2 id="post-multi">POST /multi</h2>
<p>POST a body that looks something like this:</p>
<pre><code class="lang-json">{
&quot;options&quot;: {
&quot;debug&quot;: true
},
&quot;dependencies&quot;: {
&quot;concat-stream&quot;: &quot;0.1.x&quot;,
&quot;hyperstream&quot;: &quot;0.2.x&quot;
}
}
</code></pre>
<p>&quot;options&quot; is where you get to set &quot;debug&quot;, &quot;standalone&quot;, and &quot;fullPaths&quot;.
Usually, in this case, you&#39;ll probably only really care about debug. If you
don&#39;t define &quot;options&quot;, it will default to
<code>{ &quot;debug&quot;: false, &quot;standalone&quot;: false, &quot;fullPaths&quot;: false }</code>.</p>
<p>What you get in return looks something like this:</p>
<pre><code>HTTP/1.1 200 OK
X-Powered-By: Express
Location: /multi/48GOmL0XvnRZn32bkpz75A==
content-type: application/json
Date: Sat, 22 Jun 2013 22:36:32 GMT
Connection: keep-alive
Transfer-Encoding: chunked
{
&quot;concat-stream&quot;: {
&quot;package&quot;: /* the concat-stream package.json */,
&quot;bundle&quot;: /* the concat-stream bundle */
},
&quot;hyperstream&quot;: {
&quot;package&quot;: /* the hyperstream package.json */,
&quot;bundle&quot;: /* the hyperstream bundle */
}
}
</code></pre><p>The bundle gets permanently cached at <code>/multi/48GOmL0XvnRZn32bkpz75A==</code> for
future GETs.</p>
<h2 id="get-multi-existing-bundle">GET /multi/:existing-bundle</h2>
<p>If you saved the Location url from the POST earlier, you can just GET it
instead of POSTing again.</p>
<h2 id="get-status-module">GET /status/:module</h2>
<h2 id="get-status-module-version">GET /status/:module@:version</h2>
<p>Get information on the build status of a module. Returns build information for
all versions which satisfy the given semver (or latest in the event of a
missing semver).</p>
<p>Blobs generally look something like this:</p>
<pre><code>HTTP/1.1 200 OK
X-Powered-By: Express
Access-Control-Allow-Origin: *
Content-Type: application/json; charset=utf-8
Content-Length: 109
ETag: &quot;-9450086&quot;
Date: Sun, 26 Jan 2014 08:05:59 GMT
Connection: keep-alive
{
&quot;module&quot;: &quot;concat-stream&quot;,
&quot;builds&quot;: {
&quot;1.4.1&quot;: {
&quot;ok&quot;: true
}
}
}
</code></pre><p>The &quot;module&quot; and &quot;builds&quot; fields should both exist. Keys for &quot;builds&quot; are the
versions. Properties:</p>
<ul>
<li>&quot;ok&quot;: Whether the package has last built or not</li>
<li>&quot;error&quot;: If the package was built <em>insuccessfully</em> (&quot;ok&quot; is
false), this property will contain information about the error</li>
</ul>
<p>Versions which have not been built will not be keyed onto &quot;builds&quot;.</p>
<h2 id="heroku-installation">Heroku Installation</h2>
<p>browserify-cdn is ready to run on Heroku:</p>
<pre><code class="lang-sh">heroku create my-browserify-cdn
git push heroku master
heroku ps:scale web=1
</code></pre>
<h2 id="docker-installation">Docker Installation</h2>
<p>You can build and run an image doing the following:</p>
<pre><code class="lang-sh">docker build -t &quot;wzrd.in&quot; /path/to/wzrd.in
docker run -p 8080:8080 wzrd.in
</code></pre>
<p>Keep in mind that a new deploy will wipe the cache.</p>
<h2 id="license">License</h2>
<p>MIT</p>
</div>
<div id="harry-potter">
<h1>BASICALLY IT'S PRETTY SWEET.</h1>
<img src="/img/hp.png">
</div>
</body>
</html>