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

Ideas #10

Open
johnpapa opened this issue Oct 28, 2019 · 0 comments
Open

Ideas #10

johnpapa opened this issue Oct 28, 2019 · 0 comments

Comments

@johnpapa
Copy link

Love this , sooooo much!

Here are some thoughts I had, which you may have already considered.

entry point

Could the entry point be configurable? Some folks may want it in a specific folder and in a specific file. Could we have the app follow a convention such as this?

  • use the package.json main file , if set
  • use the convention src/app.js if no main file exists

The goal is to allow for customization, but have a practical default. The main file is a conventional and familiar option. if this is not possible, perhaps the host.json

onTrigger

The app.onTrigger implies there are other things we can connect using app.on*. Could the trigger part be an argument? Could Trigger, which is arguably the most common type, be the conventional default? Then the code would look like this:

app.on(new HttpTrigger('api/bye', ['GET'], goodbyeFunction)
//or
app.on('trigger', new HttpTrigger('api/bye', ['GET'], goodbyeFunction)

We can't use the types to determine this because it has to support javascript. But perhaps if trigger is the 75% case, we should make it the default.

array or strings

Consider allowing a string or array for the methods.

app.on(new HttpTrigger('api/bye', ['GET'], goodbyeFunction)
// or
app.on(new HttpTrigger('api/bye', 'GET', goodbyeFunction)

consider method as a method? (pun intended)

Not that this now implies that this is a http trigger and the get is used instead of the on. This would mean you cant hook up multiple methods at one time ... but do most APIs allow multiples? Curious if folks do this or not.

app.get(new HttpTrigger('api/bye', goodbyeFunction)

who is listening

With node, this startup process ends usually when the server starts to listen. With this app it is implied. This is also where a lot of people console log startup messages which may include the port number, ssl usage, and sometimes all active endpoints. Would it be helpful to provide a app.listen().then( ... ) to both make it easier for people to know when it starts and where to put such messages?

port

Often the port is set in this code for Express and other servers. Could we allow port setting in this startup routine?

error handling

It would be helpful to see how errors are handled given the unique error handling process in Node middleware.

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

1 participant