express

node v14.20.1
version: 1.0.0
endpointsharetweet
const express = require("@runkit/ego/express-app/1.0.0"); const live = require("@runkit/ego/livescore-api/2.0.0"); const app = express(module.exports); const bodyParser = require('body-parser'); var jwt = require('express-jwt'); var jwks = require('jwks-rsa'); app.set('json spaces', 4); app.use(require('compression')()) app.use(bodyParser.json()); var jwtCheck = jwt({ secret: jwks.expressJwtSecret({ cache: true, rateLimit: true, jwksRequestsPerMinute: 90, jwksUri: process.env.JWKS_URI }), audience: process.env.JWKS_AUDIENCE, issuer: process.env.JWKS_ISSUER, algorithms: ['RS256'] }); app.use(jwtCheck);
app.get('/authorized', function (req, res) { res.send('Secured Resource'); });
app.get("/", (req, res) => { let hostname = req.protocol + '://' + req.headers.host; res.json({"result":{ "version": "1.0.5", "site": req.headers.host, "authorized": hostname + "/authorized", "bobotv" : hostname + "/bobosport", "livescore" : hostname +"/livescore", "matches": [{ "home": "man u", "away": "arsenal" }, { "home": "chealsea", "away": "q" } ] } }) });
app.get('/livescore', async (req,res)=>{ const score = await live.livescore(); let object = score.list; let hostname = req.protocol + '://' + req.headers.host; let element, jsonapi = []; for (const key in object) { element = object[key]; element.url = hostname + '/detail/' + element.match_id; jsonapi.push(element); }; //console.log(ok); //res.json(score.list); res.send(jsonapi); }); app.get('/detail/:id', async (req,res)=>{ let id = req.params.id; const dls = await live.detail(id); res.json(dls); }); app.get('/bobosport', async (req,res)=>{ const bo = await live.bobo(); res.json(bo); });
//app.get('/bobosport', bobo);
Loading…

no comments

    sign in to comment