@@ -6,7 +6,7 @@ require.paths.unshift('../../lib');
6
6
// Project dependencies
7
7
var express = require ( 'express' ) ,
8
8
Redis = require ( 'redis' ) ,
9
- support = require ( '../../' ) ,
9
+ middleware = require ( '../../' ) ,
10
10
browserify = require ( 'browserify' ) ,
11
11
io = require ( 'socket.io' ) ,
12
12
server = module . exports = express . createServer ( ) ,
@@ -47,84 +47,18 @@ server.get('/', function(req, res) {
47
47
res . render ( __dirname + '/index.html' ) ;
48
48
} ) ;
49
49
50
- //db.flushall();
51
-
52
- support . config ( {
53
- io : io ,
54
- database : db ,
55
- publish : pub ,
56
- subscribe : sub ,
57
- listener : 'backbone' ,
58
- safeMode : true ,
59
- showDebug : true ,
60
- showError : true
61
- } ) ;
62
-
63
-
64
- model = support
65
- . schema ( {
66
- content : '' ,
67
- order : '' ,
68
- done : ''
69
- } )
70
- . pre ( 'create' , function ( next , sock , data , cb ) {
71
- console . log ( 'todo-pre-create' ) ;
72
- next ( sock , data , cb ) ;
73
- } )
74
- . pre ( 'read' , function ( next , sock , data , cb ) {
75
- console . log ( 'todo-pre-read' ) ;
76
- next ( sock , data , cb ) ;
77
- } )
78
- . pre ( 'update' , function ( next , sock , data , cb ) {
79
- console . log ( 'todo-pre-update' ) ;
80
- next ( sock , data , cb ) ;
81
- } )
82
- . pre ( 'delete' , function ( next , sock , data , cb ) {
83
- console . log ( 'todo-pre-delete' ) ;
84
- next ( sock , data , cb ) ;
85
- } )
86
- . pre ( 'subscribe' , function ( next , sock , data , cb ) {
87
- console . log ( 'todo-pre-subscribe' ) ;
88
- next ( sock , data , cb ) ;
89
- } )
90
- . pre ( 'unsubscribe' , function ( next , sock , data , cb ) {
91
- console . log ( 'todo-pre-unsubscribe' ) ;
92
- next ( sock , data , cb ) ;
93
- } )
94
- . pre ( 'publish' , function ( next , sock , data , cb ) {
95
- console . log ( 'todo-pre-publish' ) ;
96
- next ( sock , data , cb ) ;
97
- } )
98
- . post ( 'create' , function ( next , sock , data , cb ) {
99
- console . log ( 'todo-post-create' ) ;
100
- next ( sock , data , cb ) ;
101
- } )
102
- . post ( 'read' , function ( next , sock , data , cb ) {
103
- console . log ( 'todo-post-read' ) ;
104
- next ( sock , data , cb ) ;
105
- } )
106
- . post ( 'update' , function ( next , sock , data , cb ) {
107
- console . log ( 'todo-post-update' ) ;
108
- next ( sock , data , cb ) ;
109
- } )
110
- . post ( 'delete' , function ( next , sock , data , cb ) {
111
- console . log ( 'todo-post-delete' ) ;
112
- next ( sock , data , cb ) ;
113
- } )
114
- . post ( 'subscribe' , function ( next , sock , data , cb ) {
115
- console . log ( 'todo-post-subscribe' ) ;
116
- next ( sock , data , cb ) ;
117
- } )
118
- . post ( 'unsubscribe' , function ( next , sock , data , cb ) {
119
- console . log ( 'todo-post-unsubscribe' ) ;
120
- next ( sock , data , cb ) ;
121
- } )
122
- . post ( 'publish' , function ( next , sock , data , cb ) {
123
- console . log ( 'todo-post-publish' ) ;
124
- next ( sock , data , cb ) ;
50
+ // Start up the application
51
+ if ( ! module . parent ) {
52
+ middleware ( {
53
+ io : io ,
54
+ db : db ,
55
+ publish : pub ,
56
+ subscribe : sub ,
57
+ listener : 'backbone'
125
58
} ) ;
126
59
127
- support . model ( 'todo' , model ) ;
128
-
60
+ middleware . pre ( 'room:save' , function ( model , options , next ) {
129
61
130
- server . listen ( 8080 ) ;
62
+ } ) ;
63
+ server . listen ( 8080 ) ;
64
+ }
0 commit comments