-
Hey, guys, noob here, so thank you for patience. What if I have an existing NodeJS application (single-user, for localhost access) that I want to serve an updatable TiddlyWiki instance as one of its pages - what parts of your api should I be looking at? To make it more interesting, what would be that most canonical way provide access to custom API of this existing application to the code of TiddlyWiki modules in such case? Speaking simply, I'm talking here about somehow injecting TW5 as a plugin to existing node-based platform with reasonable level of mutual integration - this should be possible, I believe. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Hi @Keyholder that is an interesting idea, and I don't think anyone has done any work in that area yet. Doing it elegantly would probably require some modest core modifications: for example, one approach would be to expose TiddlyWiki's server request handler so that the containing app could delegate requests to it. Are there any established mechanisms in this area? For example, do Express apps have a way to plugin route handlers? |
Beta Was this translation helpful? Give feedback.
-
@Jermolene I've done this! TidGi Desktop is now starting a nodejs wiki instance, and redirect its output to IPC channel. In @Keyholder 's case, you just need to redirect it to your existing nodejs service's HTTP route. Firstly, create a headless wiki (without its own http route) and store in const wikiInstance = TiddlyWiki();
// other setup, see links above, and remember don't use "plugins/tiddlywiki/tiddlyweb" here
wikiInstance.boot.startup({ bootPath: TIDDLYWIKI_PACKAGE_FOLDER }); Then use const wikiHTML = this.wikiInstance.wiki.renderTiddler('text/plain', rootTiddler);
return { statusCode: 200, headers: { 'Content-Type': 'text/html' }, data: wikiHTML }; |
Beta Was this translation helpful? Give feedback.
Hi @Keyholder if you want to experiment with re-using the route handlers, you can get a reference to them with the following code:
You'd need to fake a "state" object to pass to the route handlers along with the request and response objects.