telegraph

0.8.22 • Public • Published

Telegraph

Telegraph aims to combine Express with Socket.IO to into a reactor pattern style web framework for quickly building event heavy projects.

Get started:

npm install telegraph -g
telegraph init
npm install -d

telegraph start
// Current defaults for Telegraph
module.exports = App = new Telegraph.Server({
     'appname'        : "Telegraph",   // For aesthetic purposes, the name of the application
     'websockets'     : true,          // Enables websocket events via socket.io
     'view engine'    : 'ejs'          // The templating engine used to render views
});

Starting the Server:

telegraph start

or use foreman

foreman start

Configuration

Configure the express server like so:

App.use("middleware-name", { settings });
App.use(middlewarename, { settings });
 
App.set("setting", "value");

Routes

Follow traditional express routing

App.get("/", function(req,res) {
     res.render("index");
});
 
App.post("/article/create", function(req,res) {
     res.send("it worked!");
});
  
App.destroy("/article/destroy/:id", function(req, res) {
     res.send("it worked!");
});

Websocket Events

App.on("websocket:foo", function(data) { 
     App.send("message", data);      // for standard socket.io "emit" events"
     App.volley("message", data);    // for volatile socket.io "emit" events"
     App.broadcast("message", data);    // for broadcast socket.io "emit" events"
});

Using Databases

By default, Telegraph uses loose wrappers around Backbone Models and Collections as a temporary datastore. CouchDB can be configured in the /config/database.json file:

{
    "development" : {
 
        "adapter"      : "couch",
        "host"         : "hostname",
        "dbname"       : "database name",
        "port"         : port,
 
        "auth"         : {
            "username" : "username",
            "password" : "password"
        }
    } 
}

This will setup cradle for the above settings at App.db.


Heroku Hosting:

Telegraph is already configured for Heroku Cedar Stack. After running a telegraph init, do the following:

heroku create --stack cedar
git push heroku master

Readme

Keywords

none

Package Sidebar

Install

npm i telegraph

Weekly Downloads

43

Version

0.8.22

License

none

Last publish

Collaborators

  • nhunzaker