2 Star 0 Fork 0

lantsang / nestjs-tencent-iot

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

NestJS 腾讯云 物联网通信 服务插件

注意:仍在开发中,目前仅在内部使用

使用说明

外部人员仅供参考,请不要用于生产环境,因此导致的事故后果请自行承担。

支持环境

  • node >=14.x

安装

$ npm i @lantsang/nestjs-tencent-iot

or
$ yarn add @lantsang/nestjs-tencent-iot  # 推荐使用yarn

配置

同步方式

import { Module } from '@nestjs/common';
import { TencentIotModule } from '@lantsang/nestjs-tencent-iot'

@Module({
  imports: [
    TencentIotModule.forRoot({
      user: {
        secretId: '腾讯云子用户SecretId',
        secretKey: '腾讯云子用户SecretKey'
      },
      token: '数据转发到第三方服务器校验token'  // 选填,当在规则引擎中启用数据转发到第三方服务器时必填!
    })
  ]
})
export class AppModule { }

异步方式

import { Module } from '@nestjs/common';
import { TencentIotModule } from '@lantsang/nestjs-tencent-iot'
import { ConfigModule } from './modules/config/config.module';
import { CONFIG_PROVIDER } from './modules/config/constants/config.constant';
import { ConfigService } from './modules/config/services/config.service';

@Module({
  imports: [
    TencentIotModule.forRootAsync({
      useFactory: (configService: ConfigService) => ({
        user: {
          secretId: configService.tencent.cam.user.secretId,
          secretKey: configService.tencent.cam.user.secretKey
        },
        token: configService.tencent.iothub.token // 选填,当在规则引擎中启用数据转发到第三方服务器时必填!
      }),
      inject: [CONFIG_PROVIDER]
    }),
    ConfigModule
  ]
})
export class AppModule {}

提示:异步注册方式采用的 ConfigModule 并不是 NestJS 自带的配置功能,而是我基于官方自己设计的一套,具体实现请参考笔记:NestJS配置模块设计

文档地址

MIT License Copyright (c) 2021 lantsang Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

nestjs 对接腾讯云物联网通信插件 展开 收起
NodeJS 等 3 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
NodeJS
1
https://gitee.com/lantsang/nestjs-tencent-iot.git
git@gitee.com:lantsang/nestjs-tencent-iot.git
lantsang
nestjs-tencent-iot
nestjs-tencent-iot
v0.0

搜索帮助