Hello. I am new to developing for Rocket.Chat and I hope someone can help me with this problem.
I am trying to develop a simple slash command that makes use of the Node library ‘strong-soap’.
However, when I deploy this to the server with rc-apps deploy, the Node dependencies are not added to the package and the server is not able to locate ‘strong-soap’.
In my slashcommand.ts I have:
import {IModify, IRead} from '@rocket.chat/apps-engine/definition/accessors';
import {App} from '@rocket.chat/apps-engine/definition/App';
import {ISlashCommand, SlashCommandContext} from '@rocket.chat/apps-engine/definition/slashcommands';
import * as soap from 'strong-soap';
export class CercaCommand implements ISlashCommand {
public command = 'cerca';
public i18nDescription = '';
public i18nParamsExample = '';
public providesPreview = false;
constructor(private readonly app: App) {}
public async executor(context: SlashCommandContext, read: IRead, modify: IModify): Promise<void> {
let message: string = 'Hello!';
const messageStructure = await modify.getCreator().startMessage();
const sender = context.getSender(); // the user calling the slashcommand
const room = context.getRoom(); // the current room
messageStructure
.setSender(sender)
.setRoom(room)
.setText(message);
const urlWsdl = 'http://www.dneonline.com/calculator.asmx?wsdl';
try {
soap.soap.createClient(urlWsdl, {}, (err, client) => {
console.log('Inside client');
});
} catch (error) {
console.log(error);
}
await modify.getCreator().finish(messageStructure);
}
}
but when running /cerca the server logs the error:
rocketchat_1 | TypeError: Cannot read property 'soap' of undefined
rocketchat_1 | at CercaCommand.executor (evalmachine.<anonymous>:24:18)
rocketchat_1 | at runMicrotasks (<anonymous>)
rocketchat_1 | at processTicksAndRejections (internal/process/task_queues.js:97:5)
Is there a way to make the engine locate the strong-soap library on the server?
My server machine is a Docker container with image rocketchat/rocket.chat:latest.
Rocket.Chat version: 3.9.1
Apps engine version: 1.20.0
I tried running npm install strong-soap
on several paths in the server – including the root folder of Rocket.Chat, the one containing main.js
.
I also tried npm install -g strong-soap
.
Neither worked.