1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Updated Design: Custom Node admin route handling (markdown)

Nick O'Leary 2018-05-14 14:30:39 +01:00
parent 240444abda
commit ee604c6c8d

@ -9,6 +9,9 @@ This poses some problems for the split of the editor and runtime.
One of the goals of the split is to be able to serve the editor from a static file server (eg AWS S3) and point it at a server hosting the admin api. At this point, any relative urls a custom node uses will break - as they will be relative to the S3 url, not the admin api url.
### Editor side
There are a number of ways a user may access these custom routes - each needs a slightly different solution.
| Type of route | Resolution |
@ -23,9 +26,23 @@ There are a number of ways a user may access these custom routes - each needs a
| `<link>` inside edit template `<script>` | As with `<script>`, but this happens each time the edit dialog is opened for a node. |
| **Adding images to the page** | |
| `<img>` in edit template | As with `<script>`, but this happens each time the edit dialog is opened for a node. |
| Dynamically added via code | We cannot intercept these - no good solution to keep things working as it |
| Dynamically added via code | We cannot intercept these - no good solution to keep things working as-is |
So we can cover a number of the cases via code inspection and url rewriting - but not all. I don't know how common it is for nodes to add custom images - but its possible to do so.
So we can cover a number of the cases via code inspection and url rewriting - but not all. I don't know how common it is for nodes to add custom images - but its possible, so needs to be handled.
### Runtime side
With the split, the server side splits into two separate modules:
- The runtime module is where nodes are registered and live.
- The editor module provides the admin express app to expose the admin routes on an http server instance
with the new runtime-api used as the interface between them.
By splitting them like that, a node can no longer have direct access to the admin express app instance. Which is a *big* problem.
On the whole, they just add routes using the standard `app.get/post/del/put` functions. But some will do something more involved, such as add an instance of serveStatic (or similar) to serve up static content for the node, or allowing file upload.
To achieve a full split between the modules, the runtime-api needs to have some way of abstracting out these routes so they can be made over RPC. *There's no nice way of doing that*.