How do I change the server.js file in /backend
January 14, 2020 at 2:10amHow do I change the server.js file in /backend
January 14, 2020 at 2:10amHi,
I am following the "Communication via JSON-RPC" docs and am at the point where I have the websocket started but the handler is missing. I believe this is because I am unable to edit the /browser-app/src-gen/backend/server.js file. If I edit this file and build it is replaced by a fresh server.js file. How do I make changes here. Specifically I need to add an import for my new backend service and a container.load() on that service.
January 14, 2020 at 2:53am
If you want to do any code customizataions you need a custom Theia extension.
January 14, 2020 at 9:40pm
import { ContainerModule } from 'inversify';import { ConnectionHandler, JsonRpcConnectionHandler } from "@theia/core";import { IProblemInspectorClient, IProblemInspectorServer} from "./problem-inspector-protocol"export const problemInspectorServerModule = new ContainerModule(bind => {bind(ConnectionHandler).toDynamicValue(ctx =>new JsonRpcConnectionHandler<IProblemInspectorClient>("/problem-inspector", client => {const problemInspectorServer = ctx.container.get<IProblemInspectorServer>(IProblemInspectorServer);problemInspectorServer.setClient(client);return problemInspectorServer;})).inSingletonScope()});
I have created the above for the connection handler binding.
and in the server.js I added:
const { problemInspectorServerModule } = require('problem-inspector-extension/lib/browser/problem-inspector-server-module');container.load(problemInspectorServerModule);
not sure what you mean by
and in the server.js i added
- you should not modify this file manuallyyou should expose the backend module in
theiaExtensions
in your extension package.json, docs should cover itHi Anton, firstly I'd just like to thank you for your help. I am working on getting the code up on a repo so that you may look at it. I am basically trying to follow along this doc: https://theia-ide.org/docs/json_rpc, that will allow me to create a backend that I can call via a websocket and have that trigger a frontend event. At the end of the doc it mentions "Loading the modules in the example backend and frontend" which is why I tried to modify the server.js file. It seems like this is not the way it is done anymore. Could you point me to some docs or an example that has a backend?
I see, yes docs look outdated, in https://theia-ide.org/docs/authoring_extensions/ look at
Implementing the Extension
each extension should declare frontend/backend entry points in package.json via
theiaExtensions
attributetheia build
will analyze these declarations and generate server.jsJanuary 16, 2020 at 7:28pm