0.2.0 • Published 8 years ago

rediserve v0.2.0

Weekly downloads
4
License
MIT
Repository
github
Last release
8 years ago

rediserve - a lightning fast Redis interface for EmberJS deployments

GitHub version npm version

This is a Redis client wrapper for working with lightning fast EmberJS deployments and workflows.

Install with:

npm install rediserve

Before going any further, I have to give a huge shoutout to Matthew Ranney and all of his collaborators for creating the best node Redis client upon which this project heavily depends.

Usage example

// index.js
// Example node.js web app using rediserve to fetch the markup of
// index.html for an EmberJS app deployed using the lightning deploy methodology
// (see https://www.youtube.com/watch?v=QZVYP3cPcWQ for more on the deployment strategy)

// Load up our dependencies

var express = require('express');
var redis = require('redis');
var rediserve = require('rediserve');

// Initialize the Express app to use as our server

var app = express();

// IMPORTANT: connect rediserve to Redis database first
rediserve.connect({
        password: '|cuY9yjA&{LCsjLpE5G,<o'
    },
    function (eventName, eventMsg) { // define a callback to handle Redis database events
        console.log('Redis event: ' + eventName + ' (' + eventMsg + ')');
    });

// Route all other paths to get a single index.html since this is a single-page Ember app
app.get('/*', function (req, res) {
            // Specially route any requests with a url-defined rev variable (e.g. ?revision=3783dvb2386723v39)
            // WARNING: Don't do it this way for a production app! Make sure you somehow check or sanitize the
            // input from the request first!
            let desiredRev = req.query.revision;
            try {
                rediserve.getHtml({
                        appTag: 'ember-quickstart',
                        rev: desiredRev, // desiredRev will be undefined (default to current-content) or retrieved from the URL
                        callback: function(html) {
                            res.send(html);
                        }
                });
            } catch (e) {
                if (e instanceof rediserve.GetHtmlError) {
                    console.log('Could not retrieve HTML because ' + e.message);
                }
            }
});

// Start the server, listening on port 8080
app.listen(8080);
console.log('rediserve test server listening on port 8080...');

How to Contribute

  • Open a pull request or an issue about what you want to implement / change. I'm always looking for help to move the project forward!
  • I want this to be reliable and functional, so only submit thoroughly tested code!

Contributors

The original author of rediserve is Christian Gaetano

Matthew Ranney is the creator of the best node Redis client upon which this project heavily depends.

License

MIT

0.2.0

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago