Add matelight proxy
This commit is contained in:
parent
49a40460d9
commit
cef19a6ae5
2 changed files with 20 additions and 0 deletions
|
@ -9,6 +9,7 @@ const routePictures = require('./route/pictures');
|
||||||
const route35c3 = require('./route/35c3');
|
const route35c3 = require('./route/35c3');
|
||||||
const routeCalendar = require('./route/calendar');
|
const routeCalendar = require('./route/calendar');
|
||||||
const routeCBeamRPC = require('./route/cbeamRpc');
|
const routeCBeamRPC = require('./route/cbeamRpc');
|
||||||
|
const routeMatelight = require('./route/matelight');
|
||||||
|
|
||||||
const app = new Koa();
|
const app = new Koa();
|
||||||
const router = new Router();
|
const router = new Router();
|
||||||
|
@ -17,6 +18,7 @@ route35c3(router);
|
||||||
routePictures(router);
|
routePictures(router);
|
||||||
routeCalendar(router);
|
routeCalendar(router);
|
||||||
routeCBeamRPC(router);
|
routeCBeamRPC(router);
|
||||||
|
routeMatelight(router);
|
||||||
|
|
||||||
app
|
app
|
||||||
.use(Cors())
|
.use(Cors())
|
||||||
|
|
18
server/route/matelight.js
Normal file
18
server/route/matelight.js
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
require('isomorphic-fetch');
|
||||||
|
|
||||||
|
module.exports = (router) => {
|
||||||
|
router.get('/matelight/:command', async (ctx) => {
|
||||||
|
const { command } = ctx.params;
|
||||||
|
const res = await fetch(`http://matelight.cbrp3.c-base.org/api/${command}`);
|
||||||
|
ctx.assert((res.status === 200), res.status);
|
||||||
|
const body = await res.json();
|
||||||
|
ctx.body = body;
|
||||||
|
});
|
||||||
|
router.get('/matelight/:command/:argument', async (ctx) => {
|
||||||
|
const { command, argument } = ctx.params;
|
||||||
|
const res = await fetch(`http://matelight.cbrp3.c-base.org/api/${command}/${argument}`);
|
||||||
|
ctx.assert((res.status === 200), res.status);
|
||||||
|
const body = await res.json();
|
||||||
|
ctx.body = body;
|
||||||
|
});
|
||||||
|
};
|
Loading…
Reference in a new issue