-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Adds support for using Parse Dashboard as Express middleware #209
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
Conversation
Added support for using Parse Dashboard as a Express middleware. Project structure changes: -Moved general Parse Dashboard code to a ParseDashboard class in Parse-Dashboard\index.js -Moved CLI/NPM invoked code to Parse-Dashboard\cli\index.js -Made index.js main file of module
By analyzing the blame information on this pull request, we identified @drew-gross, @gimdongwoo and @flovilmart to be potential reviewers. |
@Gameleon12 updated the pull request. |
Just now discovered a bug in the current implementation of this issue. Since all urls for assets in the html and react.js scripts are defined as relative to the root of the server (a.k.a. I will look into fixing this. |
Extremely interested in this enhancement as well. If it helps, I mounted the parse dashboard off the /parse-dashboard/ route in this commit: mamaso@8821cbf Relevant changes were setting |
…oard into heroku_master * 'master' of https://github.com/ParsePlatform/parse-dashboard: Fix badge increment. Fixes parse-community#209 Fixes parse-community#206 Changelog
@mamaso Thanks for referencing that commit. It is indeed a very helpful pointer in the right direction. The problem with it's current form is that the relative uri's stack up on top of each other while navigating through Parse Dashboard (leading to paths such as It seems the way to go is to prefix all the uri's in the react.js files with where the Express application has mounted parse-dashboard relative to the root. I am not very proficient with React so any tips, tricks, commits etc. to help and speed things up while I'm working on this would be very welcome. |
I'm not sure you need all those changes. You just need to implement in your middleware a way to:
So if there is 1 thing to do, it's maybe just extract the handler for |
@flovilmart Redirecting all requests to index.html doesn't quite solve the issue. Because all the react urls are root relative and will strip the mount path, how can you detect whether they are actually intended for the root or for whatever path the parse dashboard is mounted on? @Gameleon12 Interesting, not the biggest expert on react either. Did you set |
@mamaso So that's even better, that allows you to do
|
program.option('--config [config]', 'the path to the configuration file'); | ||
program.option('--port [port]', 'the port to run parse-dashboard'); | ||
program.option('--allowInsecureHTTP [allowInsecureHTTP]', 'set this flag when you are running the dashboard behind an HTTPS load balancer or proxy with early SSL termination.'); | ||
class ParseDashboard { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this won't work as we don't pass it through babel AFAIK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code doesn't pass through babel, but Node.js supports some features of ECMAScript 6 (including classes, albeit only in strict mode) without the need for babel compilation. (See: https://nodejs.org/en/docs/es6/)
@flovilmart Just played around a bit and I think you're right, looks like when I did this I went a wee bit overboard on the relative urls. Here's what I think are necessary changes:
|
I'm working on something that just does that |
While splitting off the general dashboard and cli related code isn't a necessity to add middleware support, it does make the code a bit cleaner to maintain and use. In addition, initialization of Parse Dashboard as middleware in this way is consistent with how Parse Server is initialized as middleware. But I suppose using a non class based node module exports implementation would work just fine too. |
see #214. Now I need to find a way to properly set , either by temptlates or just a pure regex |
Superseded by #214. |
Added support for using Parse Dashboard as a Express middleware.
Based on Parse Server middleware.
Project structure changes:
-Wrapped Parse Dashboard code in a ParseDashboard class in
Parse-Dashboard\index.js
-Moved CLI/NPM invoked code to Parse-Dashboard\cli\index.js