A dpd resource for rendering templates on the server as well as exposing them for use in the browser.
Templates live in the root of their resource instance folder (eg. /my-project/resources/templates
) and in a partials
sub folder.
// start node.js processes on a distributed network | |
// makes sure the process is always available, even if | |
// it has to restart the process on another server | |
// essentially a distributed version of forever | |
// no client/server relationship, all ring nodes are peers | |
var ring = require('ring').join('network guid') | |
, opts = { | |
distribution: { |
#!/usr/bin/env node | |
var operation = process.argv[process.argv.length - 1]; | |
var allowed = '--decipher --cipher' | |
if(allowed.indexOf(operation) === -1) { | |
operation = '--cipher'; | |
} | |
// let us type a string |
// get all widgets | |
dpd.widgets.get(function (err, widgets) { | |
if(err) return alert(err); | |
console.log(widgets); // [Object, Object, Object, ...] | |
}) | |
// get one widget | |
dpd.widgets.first(function (err, widget) { | |
if(err) return alert(err); | |
console.log(widget); |
var data = []; | |
describe('fast array', function(){ | |
it('setup', function() { | |
var max = 9 * (1000 * 1000); | |
while(data.length < max) { | |
if(data.length === max / 2) data.push(['random', 'random value']); | |
else data.push(['key', 'value']); | |
} | |
<!doctype html> | |
<html> | |
<body data-controller="list"> | |
<ul> | |
<li data-repeat="item in items"> | |
{{ item.text }} | |
</li> | |
</ul> | |
var http = require('http') | |
, request = require('request') | |
, fs = require('fs'); | |
var server = http.createServer(function (req, res) { | |
req.pipe(fs.createWriteStream('my-file.jpg')); | |
}) | |
.listen(3000) | |
.on('listening', function () { | |
fs.createReadStream('my-file.jpg').pipe(request.post('http://localhost:3000')); |
var connect = require('connect') | |
, http = require('http'); | |
var server = http.createServer(function () { | |
console.log('foo'); // this is logged | |
}); | |
var app = connect(server); | |
app.use(function (req, res, next) { |
// this must be in your project's node_modules folder to be available from the dashboard | |
var Resource = require('deployd/lib/resource') | |
, util = require('util'); | |
function CrossOrigin() { | |
Resource.apply(this, arguments); | |
// match all urls when routing | |
this.path = '/*'; | |
} |
fail |