-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hook into http ready and start primus
- Loading branch information
Showing
6 changed files
with
140 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
exports.trailpack = require('./trailpack') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* Trailpack Configuration | ||
* | ||
* @see {@link http://trailsjs.io/doc/trailpack/config | ||
*/ | ||
module.exports = { | ||
|
||
/** | ||
* API and config resources provided by this Trailpack. | ||
*/ | ||
provides: { | ||
api: { | ||
controllers: [ ] | ||
// ... | ||
}, | ||
config: [ ] | ||
}, | ||
|
||
/** | ||
* Configure the lifecycle of this pack; that is, how it boots up, and which | ||
* order it loads relative to other trailpacks. | ||
*/ | ||
lifecycle: { | ||
configure: { | ||
/** | ||
* List of events that must be fired before the configure lifecycle | ||
* method is invoked on this Trailpack | ||
*/ | ||
listen: [ ], | ||
|
||
/** | ||
* List of events emitted by the configure lifecycle method | ||
*/ | ||
emit: [ ] | ||
}, | ||
initialize: { | ||
listen: [ ], | ||
emit: [ ] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
'use strict' | ||
|
||
const Promise = require('bluebird'); | ||
const Trailpack = require('trailpack') | ||
const Primus = require('primus'); | ||
|
||
const primusDefaults = { | ||
transformer:'engine.io' | ||
}; | ||
|
||
module.exports = class Realtime extends Trailpack { | ||
validate () { | ||
return Promise.resolve() | ||
} | ||
|
||
configure () { | ||
return Promise.resolve() | ||
} | ||
|
||
initialize () { | ||
return new Promise((res,rej)=>{ | ||
this.app.once('webserver:http:ready',(httpServer)=>{ | ||
this.app.sockets = new Primus(this.server,primusDefaults) | ||
res() | ||
}) | ||
}) | ||
} | ||
|
||
constructor (app) { | ||
super(app, { | ||
config: require('./config'), | ||
api: require('./api'), | ||
pkg: require('./package') | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{ | ||
"name": "trailpack-realtime", | ||
"version": "0.0.1", | ||
"description": "Realtime Trailpack. Synchronize the client and server via WebSockets", | ||
"homepage": "http://www.trailsjs.io/", | ||
"author": "Trails.js Team <[email protected]>", | ||
"files": [ | ||
"lib" | ||
], | ||
"contributors": [ | ||
{ | ||
"name": "Travis Webb", | ||
"url": "https://github.com/tjwebb" | ||
}, | ||
{ | ||
"name": "Alex Clavelle", | ||
"url": "https://github.com/aclave1" | ||
} | ||
], | ||
"main": "index.js", | ||
"keywords": [ | ||
"trailpack", | ||
"trails", | ||
"trailjs" | ||
], | ||
"dependencies": { | ||
"bluebird": "^3.1.1", | ||
"engine.io": "^1.6.7", | ||
"primus": "^4.0.4", | ||
"trailpack": "latest" | ||
}, | ||
"devDependencies": { | ||
"eslint-config-trails": "latest", | ||
"eslint": "^1.10", | ||
"mocha": "^2.3" | ||
}, | ||
"bundledDependencies": [ | ||
"trailpack" | ||
], | ||
"scripts": { | ||
"test": "eslint . && mocha" | ||
}, | ||
"engines": { | ||
"node": ">= 4.0.0" | ||
}, | ||
"eslintConfig": { | ||
"extends": "trails" | ||
}, | ||
"repository": "[email protected]:trailsjs/trailpack-realtime", | ||
"license": "MIT" | ||
} |