All Projects → serverless-components → tencent-egg

serverless-components / tencent-egg

Licence: MIT license
Tencent Cloud Egg.js Serverless Component

Programming Languages

javascript
184084 projects - #8 most used programming language
CSS
56736 projects
HTML
75241 projects

⚠️⚠️⚠️ 所有框架组件项目迁移到 tencent-framework-components.

Serverless Egg Tencent Cloud

腾讯云 Egg.js Serverless Component

简体中文 | English

简介

腾讯云 Egg.js Serverless Component。

目录

  1. 准备
  2. 安装
  3. 配置
  4. 部署
  5. 移除

1. 安装

通过 npm 全局安装 serverless cli

$ npm install -g serverless

2. 创建

通过如下命令,快速创建一个 eggjs 应用

$ serverless init eggjs-starter --name example
$ cd example

3. 部署

serverless.yml 文件所在的项目根目录,运行以下指令,将会弹出二维码,直接扫码授权进行部署:

serverless deploy

说明:如果鉴权失败,请参考 权限配置 进行授权。

部署完成后,控制台会打印相关的输出信息,您可以通过 ${output:${stage}:${app}:apigw.url} 的形式在其他 serverless 组件中引用该组件的 API 网关访问链接(或通过类似的形式引用该组建其他输出结果),具体的,可以查看完成的输出文档:

4. 配置

Egg 组件支持 0 配置部署,也就是可以直接通过配置文件中的默认值进行部署。但你依然可以修改更多可选配置来进一步开发该 Egg 项目。

以下是 Egg 组件的 serverless.yml配置示例:

# serverless.yml
org: orgDemo
app: appDemo
stage: dev
component: egg
name: eggDemo

inputs:
  src:
    src: ./
    exclude:
      - .env
  region: ap-guangzhou
  functionName: eggDemo
  runtime: Nodejs10.15
  apigatewayConf:
    protocols:
      - http
      - https
    environment: release

5. 移除

通过以下命令移除部署的 Egg 服务资源,包括云函数和 API 网关。

$ serverless remove

账号配置(可选)

当前默认支持 CLI 扫描二维码登录,如您希望配置持久的环境变量/秘钥信息,也可以在项目根目录 serverless-egg 中创建 .env 文件:

# .env
TENCENT_SECRET_ID=XXX
TENCENT_SECRET_KEY=XXX

如果没有腾讯云账号,可以在此 注册新账号

如果已有腾讯云账号,可以在 API 密钥管理 中获取 SecretIdSecretKey.

更多组件

可以在 Serverless Components repo 中查询更多组件的信息。

License

MIT License

Copyright (c) 2020 Tencent Cloud, Inc.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].