mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-09 04:13:17 +08:00
29 lines
1.2 KiB
JavaScript
29 lines
1.2 KiB
JavaScript
import { createProductionController } from './production.mjs';
|
|
import { installWecomRpc } from './rpc.mjs';
|
|
|
|
export const name = 'dsh-im-wecom-host';
|
|
export const inject = ['connection', 'credentials', 'webServer'];
|
|
|
|
export async function apply(ctx, config = {}) {
|
|
if (config?.controller) return installWecomRpc(ctx, config.controller, config.rpcOptions);
|
|
const production = await createProductionController(ctx, config, config.internals);
|
|
const disposeRpc = installWecomRpc(ctx, production.controller, config.rpcOptions);
|
|
ctx.effect(() => async () => production.close(), 'dsh-im: close Enterprise WeChat bot connections');
|
|
return disposeRpc;
|
|
}
|
|
|
|
export function createWecomHostPlugin(config) {
|
|
return Object.freeze({ name, inject, apply: (ctx) => apply(ctx, config) });
|
|
}
|
|
|
|
export { createConnectionSupervisor, ConnectionSupervisor } from './connection-supervisor.mjs';
|
|
export { createProductionController } from './production.mjs';
|
|
export {
|
|
WECOM_ENDPOINTS,
|
|
WECOM_RPC_CHANNEL,
|
|
WECOM_RPC_ENDPOINTS,
|
|
createWecomRpcHandler,
|
|
installWecomRpc,
|
|
} from './rpc.mjs';
|
|
export { WecomController } from '../../../../src/channels/wecom/wecom-controller.mjs';
|
|
export { WecomRuntime } from '../../../../src/channels/wecom/wecom-runtime.mjs';
|