github-status-reporter-4-travis

node v7.10.1
version: 20.0.0
endpointsharetweet
const express = require("@runkit/runkit/express-endpoint/1.0.0"); const bodyParser = require('body-parser') const Github = require("github") const app = express(exports); app.use(bodyParser.json()) app.post("/", (req, res) => { const params = req.body console.log('START', params) if(!process.env.GITHUB_ACCESS_TOKEN) { const message = 'please set your GITHUB_ACCESS_TOKEN in the runkit environment variables page' const json = JSON.stringify({ success: false, message }) return res.send(json) } if (params && params.state) { return createStatus(params, res) } const json = JSON.stringify({ success: false, message: 'incorrect params provided' }) res.send(json) }) function createStatus(params, res) { const gh = new Github(); gh.authenticate({ type: "oauth", token: process.env.GITHUB_ACCESS_TOKEN }); gh.repos.createStatus(params, error => { const success = !error const message = error && error.message const response = { success, message } const json = JSON.stringify(response) if (error) console.log('ERROR', error) res.send(json) }) }
Loading…

no comments

    sign in to comment