commit
49a40460d9
2 changed files with 20 additions and 0 deletions
|
@ -8,6 +8,7 @@ const path = require('path');
|
||||||
const routePictures = require('./route/pictures');
|
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 app = new Koa();
|
const app = new Koa();
|
||||||
const router = new Router();
|
const router = new Router();
|
||||||
|
@ -15,6 +16,7 @@ const router = new Router();
|
||||||
route35c3(router);
|
route35c3(router);
|
||||||
routePictures(router);
|
routePictures(router);
|
||||||
routeCalendar(router);
|
routeCalendar(router);
|
||||||
|
routeCBeamRPC(router);
|
||||||
|
|
||||||
app
|
app
|
||||||
.use(Cors())
|
.use(Cors())
|
||||||
|
|
18
server/route/cbeamRpc.js
Normal file
18
server/route/cbeamRpc.js
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
require('isomorphic-fetch');
|
||||||
|
|
||||||
|
module.exports = (router) => {
|
||||||
|
router.get('/rpc/:method', async (ctx) => {
|
||||||
|
const res = await fetch('http://c-beam.cbrp3.c-base.org:4254/rpc/', {
|
||||||
|
credentials: 'omit',
|
||||||
|
headers: {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
},
|
||||||
|
body: `{"jsonrpc":"2.0","id":1550009052773,"method":"${ctx.params.method}","params":""}`,
|
||||||
|
method: 'POST',
|
||||||
|
mode: 'cors',
|
||||||
|
});
|
||||||
|
ctx.assert((res.status === 200), res.status);
|
||||||
|
const body = await res.json();
|
||||||
|
ctx.body = body;
|
||||||
|
});
|
||||||
|
};
|
Loading…
Reference in a new issue