File tree 2 files changed +21
-0
lines changed
2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ const routePictures = require('./route/pictures');
9
9
const route35c3 = require ( './route/35c3' ) ;
10
10
const routeCalendar = require ( './route/calendar' ) ;
11
11
const routeCBeamRPC = require ( './route/cbeamRpc' ) ;
12
+ const routeMatelight = require ( './route/matelight' ) ;
12
13
13
14
const app = new Koa ( ) ;
14
15
const router = new Router ( ) ;
@@ -17,6 +18,7 @@ route35c3(router);
17
18
routePictures ( router ) ;
18
19
routeCalendar ( router ) ;
19
20
routeCBeamRPC ( router ) ;
21
+ routeMatelight ( router ) ;
20
22
21
23
app
22
24
. use ( Cors ( ) )
Original file line number Diff line number Diff line change
1
+ require ( 'isomorphic-fetch' ) ;
2
+
3
+ module . exports = ( router ) => {
4
+ router . post ( '/matelight/:command' , async ( ctx ) => {
5
+ const { command } = ctx . params ;
6
+ const res = await fetch ( `http://matelight.cbrp3.c-base.org/api/${ command } ` ) ;
7
+ ctx . assert ( ( res . status === 200 ) , res . status ) ;
8
+ const body = await res . json ( ) ;
9
+ ctx . body = body ;
10
+ } ) ;
11
+ router . post ( '/matelight/:command/:argument' , async ( ctx ) => {
12
+ console . log ( ctx )
13
+ const { command, argument } = ctx . params ;
14
+ const res = await fetch ( `http://matelight.cbrp3.c-base.org/api/${ command } /${ argument } ` ) ;
15
+ ctx . assert ( ( res . status === 200 ) , res . status ) ;
16
+ const body = await res . json ( ) ;
17
+ ctx . body = body ;
18
+ } ) ;
19
+ } ;
You can’t perform that action at this time.
0 commit comments