In .verb.md
where you want to inject the TOC:
<!-- toc -->
Done!
This year marks the first year that we are doing full scale rendering of our SPA application on our mobile.walmart.com Node.js tier, which has provided a number of challenges that are very different from the mostly IO-bound load of our prior #nodebf.
The infrastructure outlined for last year is the same but our Home, Item and a few other pages are prerendered on the server using fruit-loops and hula-hoop to execute an optimized version of our client-side JavaScript and provide a SEO and first-load friendly version of the site.
To support the additional CPU load concerns as peak, which we hope will be unfounded or mitigated by our work, we have also taken a variety of steps to increase cache lifetimes of the pages that are being served in this manner. In order of their impact:
In the assemble options, define the path to your assets directory:
options: {
assets: 'dist/assets'
}
Now, in your templates you can use the variable like this:
// Define a config object to load data (for templates etc) | |
var config = [ | |
// load data to the root object | |
['components/*.json'], | |
// load data to the `pkg` object | |
{name: 'pkg', src: 'package.json'}, | |
// load data to the `site` object | |
{name: 'site', src: '.assemblerc.yml'}, | |
// load data to an object named after the basename of each file | |
// e.g. foo.json is loaded to `{foo: {// data}}` |
Summary: use good/established messaging patterns like Enterprise Integration Patterns. Don't make up your own. Don't expose transport implementation details to your application.
As much as possible, I prefer to hide Rabbit's implementation details from my application. In .Net we have a Broker abstraction that can communicate through a lot of different transports (rabbit just happens to be our preferred one). The broker allows us to expose a very simple API which is basically:
# npm publish with goodies | |
# prerequisite: `npm install -g trash` | |
# `np` with an optional argument `patch`/`minor`/`major`/`<version>` | |
# defaults to `patch` | |
np() { | |
trash node_modules &>/dev/null; | |
git pull --rebase && | |
npm install && | |
npm test && | |
npm version ${1:-patch} && |
module.exports = function () { | |
// If there is an uncaught exception anywhre in your app, it will result in a proper 500 page. | |
if (Math.random() < 0.3) throw new Error("Oops, my random is low"); | |
// They don't have to happen in the first tick either | |
if (Math.random() < 0.2) return setTimeout(function () { | |
throw new Error("Delayed random bites"); | |
}); | |
// If you throw an object, it will send a JSON document to the client | |
if (Math.random() > 0.6) throw {Hello: request.url}; |