infoscreens/server/route/matelight.js

20 lines
683 B
JavaScript
Raw Permalink Normal View History

2019-05-06 20:33:01 +02:00
require('isomorphic-fetch');
module.exports = (router) => {
2019-06-03 20:21:05 +02:00
router.post('/matelight/:command', async (ctx) => {
2019-05-06 20:33:01 +02:00
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;
});
2019-06-03 20:21:05 +02:00
router.post('/matelight/:command/:argument', async (ctx) => {
console.log(ctx)
2019-05-06 20:33:01 +02:00
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;
});
};