Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make GET /probot template more flexible #53

Closed
swain opened this issue Dec 7, 2020 · 6 comments
Closed

Make GET /probot template more flexible #53

swain opened this issue Dec 7, 2020 · 6 comments

Comments

@swain
Copy link
Contributor

swain commented Dec 7, 2020

As is, the behavior of the GET /probot HTML template is brittle and non-flexible:

// views/probot.js
const { name, version } = require(`${process.cwd()}/package`);

module.exports.template = `
  ... 
`

// index.js
const { template } = require("./views/probot");
...

// `template` is rendered on `GET /probot`
  1. It relies on the presence of a package module in process.cwd() at import time. This reliance seems unnecessary, and is also undocumented in the README.

  2. This require statement is not compatible with webpack, which cannot handle a dynamic import like this.

Thoughts on updating this behavior to be configurable, or swapping the require for a safer file read?

@gr2m
Copy link
Contributor

gr2m commented Dec 7, 2020

Thank you for opening the issue!

We are currently working on making Probot work better with serverless environments out of the box, see probot/probot#1286 (comment)

The API will look something like this

const { createLamdaMiddleware, createProbot } = require('@probot/lambda')
const myApp = require('../app')

module.export = createLamdaMiddleware(myApp, { probot: createProbot() })

Question: would you expect the returned middleware to handle the GET /probot route at all? The question is if the middleware should only care about the webhook requests from GitHub, while you can define all other routes depending on what you need for your app. Would that resolve your problem?

@swain
Copy link
Contributor Author

swain commented Dec 9, 2020

Hi @gr2m! Thanks for the prompt response.

would you expect the returned middleware to handle the GET /probot route at all?

This route is not really important to me or my organization, so removing it wouldn't bother me in the slightest!

However, I think the biggest problem for us was the package's internal reliance on process.cwd() and the presence of a package.json in the deployed lambda, as this didn't play well with our deployment strategies (e.g. use of webpack, not including package.json).

@gr2m
Copy link
Contributor

gr2m commented Dec 9, 2020

okay thanks for sharing these insights.

So I think the solution will be to just remove the view by default, which is the case with the new serverless APIs.

Okay to close this issue?

@gr2m gr2m closed this as completed Dec 9, 2020
@swain
Copy link
Contributor Author

swain commented Dec 10, 2020

@gr2m My notifications are messed up -- thanks for closing, and for addressing!

@swain
Copy link
Contributor Author

swain commented Sep 18, 2023

@gr2m FWIW -- it looks like this issue is actually still present in the latest version of this package.

I'm going to put up a PR with a more detailed description.

@swain
Copy link
Contributor Author

swain commented Sep 18, 2023

@gr2m PR here, if you're interested: #120.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants