@midwayjs/mqtt 3.14.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,12 @@
1
+ # midway framework for mqtt
2
+
3
+ [![Package Quality](http://npm.packagequality.com/shield/midway-web.svg)](http://packagequality.com/#?package=midway-web)
4
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/midwayjs/midway/pulls)
5
+
6
+ this is a sub package for midway.
7
+
8
+ Document: [https://midwayjs.org](https://midwayjs.org)
9
+
10
+ ## License
11
+
12
+ [MIT]((http://github.com/midwayjs/midway/blob/master/LICENSE))
@@ -0,0 +1,7 @@
1
+ import { IMidwayContainer } from '@midwayjs/core';
2
+ import { MidwayMQTTFramework } from './framework';
3
+ export declare class MQTTConfiguration {
4
+ framework: MidwayMQTTFramework;
5
+ onReady(container: IMidwayContainer): Promise<void>;
6
+ }
7
+ //# sourceMappingURL=configuration.d.ts.map
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.MQTTConfiguration = void 0;
13
+ const core_1 = require("@midwayjs/core");
14
+ const framework_1 = require("./framework");
15
+ const service_1 = require("./service");
16
+ let MQTTConfiguration = class MQTTConfiguration {
17
+ async onReady(container) {
18
+ await container.getAsync(service_1.MqttProducerFactory);
19
+ }
20
+ };
21
+ __decorate([
22
+ (0, core_1.Inject)(),
23
+ __metadata("design:type", framework_1.MidwayMQTTFramework)
24
+ ], MQTTConfiguration.prototype, "framework", void 0);
25
+ MQTTConfiguration = __decorate([
26
+ (0, core_1.Configuration)({
27
+ namespace: 'mqtt',
28
+ importConfigs: [
29
+ {
30
+ default: {
31
+ mqtt: {
32
+ pub: {},
33
+ sub: {},
34
+ contextLoggerApplyLogger: 'mqttLogger',
35
+ },
36
+ midwayLogger: {
37
+ clients: {
38
+ mqttLogger: {
39
+ fileLogName: 'midway-mqtt.log',
40
+ },
41
+ },
42
+ },
43
+ },
44
+ },
45
+ ],
46
+ })
47
+ ], MQTTConfiguration);
48
+ exports.MQTTConfiguration = MQTTConfiguration;
49
+ //# sourceMappingURL=configuration.js.map
@@ -0,0 +1,3 @@
1
+ export declare const MQTT_DECORATOR_KEY = "rpc:mqtt";
2
+ export declare function MqttSubscriber(subscriberName: string): ClassDecorator;
3
+ //# sourceMappingURL=decorator.d.ts.map
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MqttSubscriber = exports.MQTT_DECORATOR_KEY = void 0;
4
+ const core_1 = require("@midwayjs/core");
5
+ exports.MQTT_DECORATOR_KEY = 'rpc:mqtt';
6
+ function MqttSubscriber(subscriberName) {
7
+ return target => {
8
+ (0, core_1.saveModule)(exports.MQTT_DECORATOR_KEY, target);
9
+ (0, core_1.saveClassMetadata)(exports.MQTT_DECORATOR_KEY, subscriberName, target);
10
+ (0, core_1.Scope)(core_1.ScopeEnum.Request)(target);
11
+ (0, core_1.Provide)()(target);
12
+ };
13
+ }
14
+ exports.MqttSubscriber = MqttSubscriber;
15
+ //# sourceMappingURL=decorator.js.map
@@ -0,0 +1,15 @@
1
+ import { BaseFramework } from '@midwayjs/core';
2
+ import { IMidwayMQTTApplication, IMidwayMQTTConfigurationOptions, IMidwayMQTTContext } from './interface';
3
+ import { IClientOptions, MqttClient } from 'mqtt';
4
+ export declare class MidwayMQTTFramework extends BaseFramework<IMidwayMQTTApplication, IMidwayMQTTContext, IMidwayMQTTConfigurationOptions> {
5
+ app: IMidwayMQTTApplication;
6
+ protected subscriberMap: Map<string, MqttClient>;
7
+ mqttLogger: any;
8
+ configure(): any;
9
+ applicationInitialize(options: any): Promise<void>;
10
+ run(): Promise<void>;
11
+ protected beforeStop(): Promise<void>;
12
+ createSubscriber(connectionOptions: IClientOptions, clientName?: string): Promise<MqttClient>;
13
+ getFrameworkName(): string;
14
+ }
15
+ //# sourceMappingURL=framework.d.ts.map
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.MidwayMQTTFramework = void 0;
13
+ const core_1 = require("@midwayjs/core");
14
+ const mqtt_1 = require("mqtt");
15
+ const decorator_1 = require("./decorator");
16
+ let MidwayMQTTFramework = class MidwayMQTTFramework extends core_1.BaseFramework {
17
+ constructor() {
18
+ super(...arguments);
19
+ this.subscriberMap = new Map();
20
+ }
21
+ configure() {
22
+ return this.configService.getConfiguration('mqtt');
23
+ }
24
+ async applicationInitialize(options) {
25
+ const { sub } = this.configurationOptions;
26
+ if (Object.keys(sub || {}).length === 0) {
27
+ this.mqttLogger.info('[midway-mqtt] Not found consumer config, skip init consumer');
28
+ }
29
+ // find subscriber
30
+ const mqttSubscriberModules = (0, core_1.listModule)(decorator_1.MQTT_DECORATOR_KEY);
31
+ const mqttSubscriberMap = {};
32
+ for (const subscriberModule of mqttSubscriberModules) {
33
+ const subscriberName = (0, core_1.getClassMetadata)(decorator_1.MQTT_DECORATOR_KEY, subscriberModule);
34
+ mqttSubscriberMap[subscriberName] = subscriberModule;
35
+ }
36
+ for (const customKey in sub) {
37
+ const consumer = await this.createSubscriber(sub[customKey].connectOptions);
38
+ consumer.subscribe(sub[customKey].subscribeOptions.topicObject, sub[customKey].subscribeOptions.opts, async (err, granted) => {
39
+ const ctx = this.app.createAnonymousContext();
40
+ ctx.packet = granted;
41
+ if (err) {
42
+ const result = await this.filterManager.runErrorFilter(err, ctx);
43
+ if (result.error) {
44
+ this.mqttLogger.error(err);
45
+ }
46
+ }
47
+ else {
48
+ const fn = await this.applyMiddleware(async (ctx) => {
49
+ const instance = await ctx.requestContext.getAsync(mqttSubscriberMap[customKey]);
50
+ // eslint-disable-next-line prefer-spread
51
+ return await instance['subscribe'].call(instance, ctx);
52
+ });
53
+ return await fn(ctx);
54
+ }
55
+ });
56
+ }
57
+ this.app = {};
58
+ }
59
+ async run() { }
60
+ async beforeStop() {
61
+ for (const [name, consumer] of this.subscriberMap) {
62
+ await consumer.endAsync();
63
+ this.mqttLogger.info(`[midway-mqtt] subscriber: ${name} is closed`);
64
+ }
65
+ }
66
+ async createSubscriber(connectionOptions, clientName) {
67
+ const client = await (0, mqtt_1.connectAsync)(connectionOptions);
68
+ client.on('error', err => {
69
+ this.mqttLogger.error(err);
70
+ });
71
+ if (clientName) {
72
+ this.subscriberMap.set(clientName, client);
73
+ }
74
+ return client;
75
+ }
76
+ getFrameworkName() {
77
+ return 'midway:mqtt';
78
+ }
79
+ };
80
+ __decorate([
81
+ (0, core_1.Logger)('mqttLogger'),
82
+ __metadata("design:type", Object)
83
+ ], MidwayMQTTFramework.prototype, "mqttLogger", void 0);
84
+ MidwayMQTTFramework = __decorate([
85
+ (0, core_1.Framework)()
86
+ ], MidwayMQTTFramework);
87
+ exports.MidwayMQTTFramework = MidwayMQTTFramework;
88
+ //# sourceMappingURL=framework.js.map
@@ -0,0 +1,6 @@
1
+ export * from './interface';
2
+ export { MidwayMQTTFramework as Framework } from './framework';
3
+ export { MQTTConfiguration as Configuration } from './configuration';
4
+ export * from './decorator';
5
+ export * from './service';
6
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js ADDED
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.Configuration = exports.Framework = void 0;
18
+ __exportStar(require("./interface"), exports);
19
+ var framework_1 = require("./framework");
20
+ Object.defineProperty(exports, "Framework", { enumerable: true, get: function () { return framework_1.MidwayMQTTFramework; } });
21
+ var configuration_1 = require("./configuration");
22
+ Object.defineProperty(exports, "Configuration", { enumerable: true, get: function () { return configuration_1.MQTTConfiguration; } });
23
+ __exportStar(require("./decorator"), exports);
24
+ __exportStar(require("./service"), exports);
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,24 @@
1
+ import { IConfigurationOptions, IMidwayApplication, IMidwayContext, NextFunction as BaseNextFunction, ServiceFactoryConfigOption } from '@midwayjs/core';
2
+ import type { IClientOptions, IClientSubscribeOptions, IClientSubscribeProperties, ISubscriptionMap, ISubscriptionGrant } from 'mqtt';
3
+ export interface MqttSubscriberOptions {
4
+ topicObject: string | string[] | ISubscriptionMap;
5
+ opts?: IClientSubscribeOptions | IClientSubscribeProperties;
6
+ }
7
+ export type IMidwayMQTTApplication = IMidwayApplication<IMidwayMQTTContext>;
8
+ export interface IMidwayMQTTConfigurationOptions extends IConfigurationOptions {
9
+ sub: {
10
+ [name: string]: Partial<{
11
+ connectOptions: Partial<IClientOptions>;
12
+ subscribeOptions: MqttSubscriberOptions;
13
+ }>;
14
+ };
15
+ pub: ServiceFactoryConfigOption<IClientOptions>;
16
+ }
17
+ export type IMidwayMQTTContext = IMidwayContext<{
18
+ packet: ISubscriptionGrant[];
19
+ }>;
20
+ export type Application = IMidwayMQTTApplication;
21
+ export interface Context extends IMidwayMQTTContext {
22
+ }
23
+ export type NextFunction = BaseNextFunction;
24
+ //# sourceMappingURL=interface.d.ts.map
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=interface.js.map
package/dist/mq.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ /**
2
+ * This RabbitMQ Server changed from https://github.com/JeniTurtle/egg-rabbitmq-plus/blob/master/rabbitmq.ts
3
+ */
4
+ /// <reference types="node" />
5
+ import * as amqp from 'amqp-connection-manager';
6
+ import { IRabbitMQApplication } from './interface';
7
+ import { ConsumeMessage } from 'amqplib/properties';
8
+ import { RabbitMQListenerOptions, ILogger } from '@midwayjs/core';
9
+ import type { Channel } from 'amqplib';
10
+ import { EventEmitter } from 'events';
11
+ export declare class RabbitMQServer extends EventEmitter implements IRabbitMQApplication {
12
+ protected channelManagerSet: Set<Channel>;
13
+ protected connection: amqp.AmqpConnectionManager;
14
+ protected logger: ILogger;
15
+ protected reconnectTime: any;
16
+ constructor(options?: any);
17
+ bindError(): void;
18
+ createChannel(isConfirmChannel?: boolean): Promise<any>;
19
+ connect(url: any, socketOptions: any): Promise<void>;
20
+ createConsumer(listenerOptions: RabbitMQListenerOptions, listenerCallback: (msg: ConsumeMessage | null, channel: Channel, channelWrapper: any) => Promise<void>): Promise<void>;
21
+ protected closeConnection(): Promise<void>;
22
+ close(): Promise<void>;
23
+ }
24
+ //# sourceMappingURL=mq.d.ts.map
package/dist/mq.js ADDED
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ /**
3
+ * This RabbitMQ Server changed from https://github.com/JeniTurtle/egg-rabbitmq-plus/blob/master/rabbitmq.ts
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.RabbitMQServer = void 0;
7
+ const amqp = require("amqp-connection-manager");
8
+ const events_1 = require("events");
9
+ class RabbitMQServer extends events_1.EventEmitter {
10
+ constructor(options = {}) {
11
+ var _a;
12
+ super();
13
+ this.channelManagerSet = new Set();
14
+ this.connection = null;
15
+ this.logger = options.logger;
16
+ this.reconnectTime = (_a = options.reconnectTime) !== null && _a !== void 0 ? _a : 10 * 1000;
17
+ this.bindError();
18
+ }
19
+ bindError() {
20
+ this.on('error', err => {
21
+ this.logger.error(err);
22
+ });
23
+ }
24
+ createChannel(isConfirmChannel = false) {
25
+ if (!isConfirmChannel) {
26
+ return this.connection.connection.createChannel();
27
+ }
28
+ else {
29
+ return this.connection.connection.createConfirmChannel();
30
+ }
31
+ }
32
+ async connect(url, socketOptions) {
33
+ this.connection = await amqp.connect(url, socketOptions);
34
+ // 监听在设置创建 channel 的错误
35
+ this.connection.on('error', err => {
36
+ if (err) {
37
+ if (err.err) {
38
+ err = err.err;
39
+ }
40
+ this.logger.error('Message Queue error', err);
41
+ }
42
+ else {
43
+ this.logger.info('Message Queue disconnected!');
44
+ }
45
+ });
46
+ await new Promise((resolve, reject) => {
47
+ // 监听 成功连接 的通知
48
+ this.connection.on('connect', () => {
49
+ this.logger.info('Message Queue connected!');
50
+ resolve();
51
+ });
52
+ // 监听 连接失败的错误 通知
53
+ this.connection.on('connectFailed', err => {
54
+ if (err) {
55
+ if (err.err) {
56
+ err = err.err;
57
+ }
58
+ this.logger.error('Message Queue disconnected', err);
59
+ }
60
+ else {
61
+ this.logger.info('Message Queue disconnected!');
62
+ }
63
+ reject(err);
64
+ });
65
+ });
66
+ }
67
+ async createConsumer(listenerOptions, listenerCallback) {
68
+ const channelWrapper = this.connection.createChannel({
69
+ setup: (channel) => {
70
+ var _a, _b, _c;
71
+ // `channel` here is a regular amqplib `ConfirmChannel`.
72
+ const channelHandlers = [];
73
+ // create queue
74
+ channelHandlers.push(channel.assertQueue(listenerOptions.queueName, Object.assign({ durable: true }, listenerOptions)));
75
+ if (listenerOptions.exchange) {
76
+ // create exchange
77
+ channelHandlers.push(channel.assertExchange(listenerOptions.exchange, (_b = (_a = listenerOptions.exchangeOptions) === null || _a === void 0 ? void 0 : _a.type) !== null && _b !== void 0 ? _b : 'topic', listenerOptions.exchangeOptions));
78
+ // bind exchange and queue
79
+ channelHandlers.push(channel.bindQueue(listenerOptions.queueName, listenerOptions.exchange, listenerOptions.routingKey || listenerOptions.pattern, listenerOptions.exchangeOptions));
80
+ }
81
+ channelHandlers.push(channel.prefetch((_c = listenerOptions.prefetch) !== null && _c !== void 0 ? _c : 1));
82
+ // listen queue
83
+ channelHandlers.push(channel.consume(listenerOptions.queueName, async (msg) => {
84
+ await listenerCallback(msg, channel, channelWrapper);
85
+ }, listenerOptions.consumeOptions));
86
+ return Promise.all(channelHandlers);
87
+ },
88
+ json: true,
89
+ });
90
+ return channelWrapper.waitForConnect();
91
+ }
92
+ async closeConnection() {
93
+ try {
94
+ if (this.connection) {
95
+ await this.connection.close();
96
+ }
97
+ this.logger.debug('Message Queue connection close success');
98
+ }
99
+ catch (err) {
100
+ this.logger.error('Message Queue connection close error', err);
101
+ }
102
+ finally {
103
+ this.connection = null;
104
+ }
105
+ }
106
+ async close() {
107
+ this.logger.debug('Message Queue will be close');
108
+ await this.closeConnection();
109
+ }
110
+ }
111
+ exports.RabbitMQServer = RabbitMQServer;
112
+ //# sourceMappingURL=mq.js.map
@@ -0,0 +1,18 @@
1
+ import { ServiceFactory } from '@midwayjs/core';
2
+ import { MqttClient } from 'mqtt';
3
+ export declare class MqttProducerFactory extends ServiceFactory<MqttClient> {
4
+ logger: any;
5
+ pubConfig: any;
6
+ getName(): string;
7
+ init(): Promise<void>;
8
+ protected createClient(config: any, clientName: any): Promise<MqttClient>;
9
+ destroyClient(producer: any): Promise<void>;
10
+ }
11
+ export declare class DefaultMqttProducer implements MqttClient {
12
+ private mqttProducerFactory;
13
+ protected instance: MqttClient;
14
+ init(): Promise<void>;
15
+ }
16
+ export interface DefaultMqttProducer extends MqttClient {
17
+ }
18
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.DefaultMqttProducer = exports.MqttProducerFactory = void 0;
13
+ const core_1 = require("@midwayjs/core");
14
+ const core_2 = require("@midwayjs/core");
15
+ const mqtt_1 = require("mqtt");
16
+ let MqttProducerFactory = class MqttProducerFactory extends core_2.ServiceFactory {
17
+ getName() {
18
+ return 'mqtt';
19
+ }
20
+ async init() {
21
+ await this.initClients(this.pubConfig);
22
+ }
23
+ async createClient(config, clientName) {
24
+ const producer = await new Promise((resolve, reject) => {
25
+ (0, mqtt_1.connectAsync)(config)
26
+ .then(client => {
27
+ client.on('error', err => {
28
+ this.logger.error(err);
29
+ });
30
+ client.on('connect', () => {
31
+ resolve(client);
32
+ });
33
+ })
34
+ .catch(reject);
35
+ });
36
+ this.logger.info('[midway-mqtt] producer: %s is ready', clientName);
37
+ return producer;
38
+ }
39
+ async destroyClient(producer) {
40
+ await producer.endAsync();
41
+ }
42
+ };
43
+ __decorate([
44
+ (0, core_1.Logger)('mqttLogger'),
45
+ __metadata("design:type", Object)
46
+ ], MqttProducerFactory.prototype, "logger", void 0);
47
+ __decorate([
48
+ (0, core_1.Config)('mqtt.pub'),
49
+ __metadata("design:type", Object)
50
+ ], MqttProducerFactory.prototype, "pubConfig", void 0);
51
+ __decorate([
52
+ (0, core_1.Init)(),
53
+ __metadata("design:type", Function),
54
+ __metadata("design:paramtypes", []),
55
+ __metadata("design:returntype", Promise)
56
+ ], MqttProducerFactory.prototype, "init", null);
57
+ MqttProducerFactory = __decorate([
58
+ (0, core_1.Provide)(),
59
+ (0, core_1.Scope)(core_1.ScopeEnum.Singleton)
60
+ ], MqttProducerFactory);
61
+ exports.MqttProducerFactory = MqttProducerFactory;
62
+ let DefaultMqttProducer = class DefaultMqttProducer {
63
+ async init() {
64
+ this.instance = this.mqttProducerFactory.get(this.mqttProducerFactory.getDefaultClientName() || 'default');
65
+ if (!this.instance) {
66
+ throw new core_2.MidwayCommonError('mqtt default producer instance not found.');
67
+ }
68
+ }
69
+ };
70
+ __decorate([
71
+ (0, core_1.Inject)(),
72
+ __metadata("design:type", MqttProducerFactory)
73
+ ], DefaultMqttProducer.prototype, "mqttProducerFactory", void 0);
74
+ __decorate([
75
+ (0, core_1.Init)(),
76
+ __metadata("design:type", Function),
77
+ __metadata("design:paramtypes", []),
78
+ __metadata("design:returntype", Promise)
79
+ ], DefaultMqttProducer.prototype, "init", null);
80
+ DefaultMqttProducer = __decorate([
81
+ (0, core_1.Provide)(),
82
+ (0, core_1.Scope)(core_1.ScopeEnum.Singleton)
83
+ ], DefaultMqttProducer);
84
+ exports.DefaultMqttProducer = DefaultMqttProducer;
85
+ (0, core_2.delegateTargetAllPrototypeMethod)(DefaultMqttProducer, mqtt_1.MqttClient);
86
+ //# sourceMappingURL=service.js.map
package/index.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import { IMidwayMQTTConfigurationOptions } from './dist';
2
+ export * from './dist/index';
3
+
4
+ declare module '@midwayjs/core/dist/interface' {
5
+ interface MidwayConfig {
6
+ mqtt?: PowerPartial<IMidwayMQTTConfigurationOptions>;
7
+ }
8
+ }
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@midwayjs/mqtt",
3
+ "version": "3.14.12",
4
+ "description": "Midway Framework for mqtt",
5
+ "main": "dist/index.js",
6
+ "typings": "index.d.ts",
7
+ "scripts": {
8
+ "build": "tsc",
9
+ "test": "node --require=ts-node/register ../../node_modules/.bin/jest --runInBand",
10
+ "cov": "node --require=ts-node/register ../../node_modules/.bin/jest --runInBand --coverage --forceExit",
11
+ "lint:fix": "../../node_modules/.bin/mwts fix"
12
+ },
13
+ "keywords": [
14
+ "midway",
15
+ "IoC",
16
+ "framework",
17
+ "mqtt"
18
+ ],
19
+ "files": [
20
+ "dist/**/*.js",
21
+ "dist/**/*.d.ts",
22
+ "index.d.ts"
23
+ ],
24
+ "license": "MIT",
25
+ "devDependencies": {
26
+ "@midwayjs/mock": "^3.14.12",
27
+ "@midwayjs/core": "^3.14.12"
28
+ },
29
+ "dependencies": {
30
+ "mqtt": "5.3.5"
31
+ },
32
+ "author": "Harry Chen <czy88840616@gmail.com>",
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "https://github.com/midwayjs/midway.git"
36
+ },
37
+ "engines": {
38
+ "node": ">=16"
39
+ },
40
+ "gitHead": "a603d2348d6141f8f723901498f03a162a037708"
41
+ }