question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make probot usable with RunKit

See original GitHub issue

Feature Request - probot in RunKit

Users want to use probot with RunKit instead of self-hosted NodeJS or platforms like Glitch

Background

RunKit notebooks are interactive javascript playgrounds connected to a complete node environment right in your browser. Every npm module pre-installed. RunKit can host any notebook as an endpoint if required.

Solution

Add a method for starting probot from within a RunKit Notebook (start probot from inside JavaScript code, instead of from the command line)

This might already be possible by using the .createProbot method or the .start, although I doubt it by inspecting the structure of the probot object/class.

I would propose a .createEndpoint method for probot. That method would create an importable endpoint for either NodeJS itself or even framework like express. The following code shows the proposed method in action.

A: (using pure NodeJS)

var probot = require("probot");

exports.endpoint = probot.createEndpoint(app => {
  // your `probot` code here
}, options)

B: (using ExpressJS)

var probot = require("probot");
var express = require("@runkit/runkit/express-endpoint/1.0.0");
var app = express(exports);

app.use(probot.createEndpoint(app => {
  // your `probot` code here
}, options));

The first argument would be the standard app function that is passed to the export for probot. The second argument would be an options object containing the same options that the probot-run script can take.

The introduced method should ideally return an object with the same signature as the callback passed to server.listen in NodeJS directly. The only change here is removing the explicit server creation and port binding.

Teachability, Documentation, Adoption, Migration Strategy The change should not be too complex for someone very versed with the project. No migration required as only functionality is added.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:20 (11 by maintainers)

github_iconTop GitHub Comments

3reactions
JasonEtcocommented, Dec 13, 2019

I did a quick test to see if this works correctly now; using @tcbyrd’s code example but with a newer version of Probot, I was able to see errors in actual Probot code:

image

This is great - it means that now Probot code is being run, it tries to start up but is missing environment variables. One could set those (e.g. process.env.APP_ID = 123) before running Probot.run.

I’ll close this out 🎉

2reactions
JasonEtcocommented, Dec 12, 2018

@jannik-mohemian 👋 this is indeed very similar to https://github.com/probot/friction/issues/8 - by grabbing the code used in probot run, you can start it with a programmatic API. We’d still like to have this kind of setup as a first-class API, but in the meantime this might help get you started:

const express = require('@runkit/runkit/express-endpoint/1.0.0')
const { createProbot } = require('probot') 

const probot = createProbot({
  id: process.env.APP_ID,
  port: process.env.PORT || 3000,
  secret: process.env.WEBHOOK_SECRET,
  cert: process.env.PRIVATE_KEY
})

const myProbotApp = app => {
  app.on('...')
}

probot.load(myProbotApp)

// Register the sub-app against Runkit's special Express app
const runkitApp = express(exports)
runkitApp.use(probot.server)

Let me know if that helps! I’m not sure how you can get a Webhook URL for GitHub to send webhooks to your Runkit app so that might be a challenge - very curious to hear what you do!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Developing an app - Probot
To develop a Probot app, you will first need a recent version of Node.js installed. ... create-probot-app is the best way to start...
Read more >
RunKit + npm: discord.js-bot
RunKit notebooks are interactive javascript playgrounds connected to a complete node environment right in your browser. Every npm module pre-installed.
Read more >
npm pino
This means that: Individuals making significant and valuable contributions are given commit-access to the ... Sign Up for Free RunKit + Try any...
Read more >
Pro-Bot
Key Focus 1 - Create a simple program using basic commands . ... The Pro-Bot has been designed to be compatible with K'Nex....
Read more >
probot-commands - npm
A Probot extension that adds slash commands to GitHub. Latest version: 1.1.0, last published: 4 years ago. Start using probot-commands in ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found