@@ -48,17 +48,8 @@ var bodyParser = require('body-parser');
4848var app = express ( ) ;
4949
5050var serverAuthenticator = require ( './auth/serverAuthenticator' ) ;
51- var roomsResource = require ( './resource/roomsResource' ) ;
52- var roomResource = require ( './resource/roomResource' ) ;
53- var tokensResource = require ( './resource/tokensResource' ) ;
5451var servicesResource = require ( './resource/servicesResource' ) ;
5552var serviceResource = require ( './resource/serviceResource' ) ;
56- var participantsResource = require ( './resource/participantsResource' ) ;
57- var streamsResource = require ( './resource/streamsResource' ) ;
58- var streamingOutsResource = require ( './resource/streamingOutsResource' ) ;
59- var recordingsResource = require ( './resource/recordingsResource' ) ;
60- var sipcallsResource = require ( './resource/sipcallsResource' ) ;
61- var analyticsResource = require ( './resource/analyticsResource' ) ;
6253
6354// parse application/x-www-form-urlencoded
6455app . use ( bodyParser . urlencoded ( { extended : true } ) )
@@ -77,7 +68,7 @@ app.options('*', function(req, res) {
7768} ) ;
7869
7970// Only following paths need authentication.
80- var authPaths = [ '/rooms*' , '/v1/rooms*' , '/services*' , '/cluster*' ] ;
71+ var authPaths = [ '/v1/ rooms*' , '/v1.1 /rooms*' , '/services*' , '/cluster*' ] ;
8172app . get ( authPaths , serverAuthenticator . authenticate ) ;
8273app . post ( authPaths , serverAuthenticator . authenticate ) ;
8374app . delete ( authPaths , serverAuthenticator . authenticate ) ;
@@ -90,64 +81,13 @@ app.get('/services', servicesResource.represent);
9081app . get ( '/services/:service' , serviceResource . represent ) ;
9182app . delete ( '/services/:service' , serviceResource . deleteService ) ;
9283
93- ////////////////////////////////////////////////////////////////////////////////////////////
94- // v1 interface begin
95- // /////////////////////////////////////////////////////////////////////////////////////////
96-
97- //Room management
98- app . post ( '/v1/rooms' , roomsResource . createRoom ) ; //FIXME: The definition of 'options' needs to be refined.
99- app . get ( '/v1/rooms' , roomsResource . represent ) ; //FIXME: The list result needs to be simplified.
100- app . get ( '/v1/rooms/:room' , roomResource . represent ) ; //FIXME: The detailed format of a complete room configuration data object needs to be refined.
101- app . delete ( '/v1/rooms/:room' , roomResource . deleteRoom ) ;
102- app . put ( '/v1/rooms/:room' , roomResource . updateRoom ) ;
103- app . patch ( '/v1/rooms/:room' , ( req , res , next ) => next ( new e . AppError ( 'Not implemented' ) ) ) ; //FIXME: To be implemented.
104-
105- //Room checker for all the sub-resources
106- app . use ( '/v1/rooms/:room/*' , roomResource . validate ) ;
107-
108- //Participant management
109- app . get ( '/v1/rooms/:room/participants' , participantsResource . getList ) ;
110- app . get ( '/v1/rooms/:room/participants/:participant' , participantsResource . get ) ;
111- app . patch ( '/v1/rooms/:room/participants/:participant' , participantsResource . patch ) ;
112- app . delete ( '/v1/rooms/:room/participants/:participant' , participantsResource . delete ) ;
113-
114- //Stream(including external streaming-in) management
115- app . get ( '/v1/rooms/:room/streams' , streamsResource . getList ) ;
116- app . get ( '/v1/rooms/:room/streams/:stream' , streamsResource . get ) ;
117- app . patch ( '/v1/rooms/:room/streams/:stream' , streamsResource . patch ) ;
118- app . delete ( '/v1/rooms/:room/streams/:stream' , streamsResource . delete ) ;
119- app . post ( '/v1/rooms/:room/streaming-ins' , streamsResource . addStreamingIn ) ; //FIXME: Validation on body.type === 'streaming' is needed.
120- app . delete ( '/v1/rooms/:room/streaming-ins/:stream' , streamsResource . delete ) ;
121-
122- //External streaming-out management
123- app . get ( '/v1/rooms/:room/streaming-outs' , streamingOutsResource . getList ) ;
124- app . post ( '/v1/rooms/:room/streaming-outs' , streamingOutsResource . add ) ; //FIXME: Validation on body.type === 'streaming' is needed.
125- app . patch ( '/v1/rooms/:room/streaming-outs/:id' , streamingOutsResource . patch ) ;
126- app . delete ( '/v1/rooms/:room/streaming-outs/:id' , streamingOutsResource . delete ) ;
127-
128- //Server side recording management
129- app . get ( '/v1/rooms/:room/recordings' , recordingsResource . getList ) ;
130- app . post ( '/v1/rooms/:room/recordings' , recordingsResource . add ) ; //FIXME: Validation on body.type === 'recording' is needed.
131- app . patch ( '/v1/rooms/:room/recordings/:id' , recordingsResource . patch ) ;
132- app . delete ( '/v1/rooms/:room/recordings/:id' , recordingsResource . delete ) ;
133-
134- //Sip call management
135- app . get ( '/v1/rooms/:room/sipcalls' , sipcallsResource . getList ) ;
136- app . post ( '/v1/rooms/:room/sipcalls' , sipcallsResource . add ) ;
137- app . patch ( '/v1/rooms/:room/sipcalls/:id' , sipcallsResource . patch ) ;
138- app . delete ( '/v1/rooms/:room/sipcalls/:id' , sipcallsResource . delete ) ;
139-
140- //Analytic management
141- app . get ( '/v1/rooms/:room/analytics' , analyticsResource . getList ) ;
142- app . post ( '/v1/rooms/:room/analytics' , analyticsResource . add ) ;
143- app . delete ( '/v1/rooms/:room/analytics/:id' , analyticsResource . delete ) ;
144-
145- //Create token.
146- app . post ( '/v1/rooms/:room/tokens' , tokensResource . create ) ;
147-
148- ////////////////////////////////////////////////////////////////////////////////////////////
149- // v1 interface end
150- // /////////////////////////////////////////////////////////////////////////////////////////
84+ // API for version 1.0.
85+ var routerV1 = require ( './resource/v1' ) ;
86+ app . use ( '/v1' , routerV1 ) ;
87+
88+ // API for version 1.1.
89+ var routerV1_1 = require ( './resource/v1.1' ) ;
90+ app . use ( '/v1.1' , routerV1_1 ) ;
15191
15292// for path not match
15393app . use ( '*' , function ( req , res , next ) {
0 commit comments