2 Star 3 Fork 0

Serverless Devs / core

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

npm version npm download node.js version license

Serverless Devs Core 是 Serverless Devs 的官方组件。由于该组件默认支持了包括组件加载日志输出组件参数转换状态上报等在内的通用 Serverless Package 开发能力,所以,通过该组件可以帮助 Serverless Package 开发者快速实现 Serverless Devs 的组件开发。

快速安装

组件开发者需要先进行 Node.js(>=10.8.0) 与 NPM 包管理工具的安装,然后通过npm指令即可完成@serverless-devs/core的安装,例如:

npm i @serverless-devs/core -S

使用方法

Serverless Devs Core 提供了decorator 使用方式类使用方式等两种使用方法。其中decorator 使用方式是官方所推荐和鼓励的使用方法。

logger能力为例,decorator 使用方式的案例代码为:

decorator 使用方式

const { HLogger, ILogger } = require('@serverless-devs/core');

class LoggerDemo {
  @HLogger('S-CORE') logger: ILogger;

  getDefaultLog() {
    this.logger.info('abc');
  }
}

类使用方式

logger能力为例,类使用方式的案例代码可以有两种方法。

  • 方法1:
    const { Logger } = require('@serverless-devs/core');
    function loggerDemo() {
      const logger = new Logger('S-CORE');
      logger.info('abc');
    }
  • 方法2:
    const { Logger } = require('@serverless-devs/core');
    
    function loggerDemo() {
      Logger.info('S-CORE', 'abc');
    }

效果展示

无论是上面的哪种使用方法,最终的效果如下:

Demo

接口目录

项目贡献

我们非常希望您可以和我们一起贡献这个项目。贡献内容包括不限于代码的维护、应用/组件的贡献、文档的完善等,更多详情可以参考 🏆 贡献指南

开源许可

Serverless Devs 遵循 MIT License 开源许可。

位于node_modules和外部目录中的所有文件都是本软件使用的外部维护库,具有自己的许可证;我们建议您阅读它们,因为它们的条款可能与MIT License的条款不同。

交流社区

您如果有关于错误的反馈或者未来的期待,您可以在 Issues 中进行反馈和交流。如果您想要加入我们的讨论组或者了解 Serverless Devs Core 的最新动态,您可以通过以下渠道进行:

关注微信公众号:serverless 联系微信小助手:xiaojiangwh 加入钉钉交流群:33947367
MIT License Copyright (c) 2021 Serverless Devs 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.

简介

:hammer: The core components related to Serverless Devs are used together with component. 展开 收起
TypeScript 等 3 种语言
MIT
取消

发行版 (180)

全部

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/serverless-devs/core.git
git@gitee.com:serverless-devs/core.git
serverless-devs
core
core
master

搜索帮助