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

Librarify index.js, so that existing express apps can be re-used #2

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

jstevans
Copy link

@jstevans jstevans commented Apr 3, 2019

I'd like to self-host this, but preferably on my existing express instance so that I can continue to use the same port. To that end, I moved the bulk of the code into a new utils.js and wrapped it in two functions:

  • getExpressRoutes(), which optionally takes in config for endpoint URLs, clientId/secret, host, and port, and returns a function with a dictionary { [endpoint: 'oauth' | 'tokenRefresh' | 'render'] : { route: string, callbacks: Function[] } } that a consumer can plug into their own express instance.
  • configureApp() which calls getExpressRoutes() and adds them to an express instance -- which can be passed in, or else one is made for the caller.

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

Successfully merging this pull request may close these issues.

1 participant