node-ember-cli-deploy-azure-tables
v0.3.0
Published
An ExpressJS middleware to serve EmberJS apps deployed by ember-cli-deploy and using Azure Table Storage
Downloads
18
Maintainers
Readme
node-ember-cli-deploy-azure-tables
ExpressJS middleware to fetch the current (or specified) revision of your Ember App from Azure Tables deployed by ember-cli-deploy.
Why?
ember-cli-deploy is great. It allows you to run
multiple versions in production at the same time and view revisions without impacting users.
However, the example provided uses koa
and many of us are not. This package allows you to easily fetch current and specified index.html
revisions from Azure Table storage.
Deploying to Azure via Ember CLI
Check out the excellent ember-cli-deploy-azure addon by duizendnegen!
Installation
npm install node-ember-cli-deploy-azure-tables
Usage
There are two ways of using the package:
ExpressJS Middleware
require
the packageuse
the package in your app
Example
var express = require('express');
var app = express();
var nodeEmberCliDeployAzureTables = require('node-ember-cli-deploy-azure-tables');
app.use('/*', nodeEmberCliDeployAzureTables({
accountName: 'AZURE_STORAGE_ACCOUNT_NAME',
accessKey: 'AZURE_STORAGE_ACCESS_KEY'
}, 'myapp'));
Fetching a Specific Revision
You can fetch a specific revision by using the index_key
query param. Example:
http://www.coolio.com?index_key=abc123
Documentation
nodeEmberCliDeployAzureTables(connectionInfo, keyPrefix, options)
(middleware constructor)
connectionInfo
(object, required) - the configuration to connect to azure tables.accountName
(required) - azure storage account nameaccessKey
(required) - azure storage account key
keyPrefix
(required) - the application name, specified for ember deploy
the keys in azure tables are prefaced with this name. For instance, if your azure table keys aremy-app:index:current
, you'd passmy-app:index
.options
(optional) - a hash of params to override the defaults
options
azureTableName
(defaults toemberdeploy
) overrides the default table name from which to fetchrevisionQueryParam
(defaults toindex_key
)
the query parameter to specify a revision (e.g.http://example.org/?index_key=abc123
). the key will be automatically prefaced with yourkeyPrefix
for security.memoize
(defaults tofalse
) enable memoizing azure storage. see the memoization section for more details.memoizeOpts
customize memoization parameters. see the memoization section for more details.
Memoization
Since the majority of the requests will be serving the current
version of your
app, you can enable memoization to reduce the load on Azure Tables. By default, memoization
is disabled. To enable it, simply pass:
memoize: true
in your options hash. Additionally, you can pass options to the underlying memoization library (memoizee). Check out their documentation, and the defaults for this library.
Example
app.use('/*', nodeEmberCliDeployAzureTables({
accountName: 'AZURE_STORAGE_ACCOUNT_NAME',
accessKey: 'AZURE_STORAGE_ACCESS_KEY'
},
'myapp',
{ memoize: true },
));
Credit
This is a modified version of Ben Limmer's excellent node-ember-cli-deploy-redis package. Thanks, Ben!
Contributing
Comments/PRs/Issues are welcome!