prerender/prerender-node — pull request #14 by mikepugh (2014-02-17 03:01:29+00:00)
Title: Support parse.com hosting

Parse.com Cloud Code hosting provides a great & scalable server for static AngularJS sites. Out of the box, the prerender-node code won't run on their platform. I've modified the code to get it working with Parse.

To get it running, go through the [Parse Docs](https://parse.com/docs/hosting_guide#started) through [Dynamic Websites](https://parse.com/docs/hosting_guide#webapp). Add the parse compatible prerender-node JS file into the ./cloud/ folder next to app.js and main.js.

Within app.js, do the following:

````javascript
var express = require('express');
var app = express();

app.use(require('cloud/prerenderio.js').set('prerenderToken','YOUR_TOKEN'));

// Global app configuration section
app.set('views', 'cloud/views'); // Specify the folder to find templates
app.set('view engine', 'ejs'); // Set the template engine
app.use(express.bodyParser()); // Middleware for reading request body

app.get('/', function(req, res) {
res.render('hello', {message: 'Some stuff..'});
});

// This is an example of hooking up a request handler with a specific request
// path and HTTP verb using the Express routing API.
app.get('/hello', function(req, res) {
res.render('hello', { message: 'Congrats, you just set up your app!' });
});

// // Example reading from the request query string of an HTTP get request.
app.get('/test', function(req, res) {
// GET http://example.parseapp.com/test?message=hello
res.send(req.query.message);
});

// // Example reading from the request body of an HTTP post request.
// app.post('/test', function(req, res) {
// // POST http://example.parseapp.com/test (with request body "message=hello")
// res.send(req.body.message);
// });

// Attach the Express app to Cloud Code.
app.listen();
````

You can't just upload your index.html file into the ./public/ folder and have it served statically because then it'll bypass the express node server with its prerender.io hook.

Instead, your index.html file, in the above example, is stored as ./cloud/views/hello.ejs. This way it will be served up by node and the prerender middleware will run.

Any other static content (angular view HTML files, module JS files, etc) should be stored in ./public/