1.2.2 • Published 2 years ago

@midwayjs/simple-lock v1.2.2

Weekly downloads
297
License
MIT
Repository
github
Last release
2 years ago

Midway Faas

查看详细文档

快速开始

国内用户建议使用 cnpm 加速npm,npm install -g cnpm --registry=https://registry.npm.taobao.org

第一步:安装 serverless

$ npm i -g serverless

第二步:创建项目

$ serverless install --url https://github.com/midwayjs/midway-faas-examples/tree/master/demo-faas

第三步:进入目录

$ cd demo-faas

第四步:安装npm依赖

$ npm i

如何使用?

invoke 本地调用 & 本地调试

$ serverless invoke -f index

// debug 需要 node 10.15 +
$ serverless invoke -f index --debug
参数释义
-f / --function funcName指定要调用的函数名
--debug=debugPort?开启debug,并且指定调试端口,默认端口为 9229

package 打包构建

$ serverless package
参数释义
--package指定打包结果(zip)文件名 --package=dist
--npm=npmName指定npm镜像,例如 --npm=cnpm
--skipZip打包的结果跳过压缩生成 zip

deploy 部署到线上

$ serverless deploy

支持所有 package 命令的参数

参数释义
--resetConfig使用新的账户

for aliyun

阿里云部署首次需要配置 accountIdaccountKeyaccountSecret

npm.io

相关配置获取,可参照下方图片(可点击跳转):

npm.io

npm.io

For Tencent SCF

  1. 用户信息认证:
    • 腾讯云在部署时,如果是首次部署,则控制台会展示相应二维码,扫码即可完成认证,后续会默认复用该配置
    • 后续如想修改部署时的使用的用户,可手动在 serverless.yml 中设置当前用户的认证信息,教程:https://cloud.tencent.com/document/product/1154/38811
  2. 部署网关设置
    • 腾讯云在部署时,会为函数默认创建网关触发器
    • 如果想避免重复创建,可按下列教程操作

发布完成后,控制台会默认显示腾讯云此次创建的网关 serviceId(如下图所示) npm.io

此时需要修改 serverless.yml 的配置文件,serviceId 可以配在以下两处:

  1. provider

此处配置则对所有函数生效,所有函数共享一个网关 serviceId

provider:
  name: tencent
  runtime: Nodejs8.9
  serviceId: <控制台返回的 ServiceId>
  1. events/http

此处配置则对指定函数生效

functions:
  index:
    initializer: index.initializer
    handler: index.handler
    events:
      - http:
          method: get
          serviceId: <控制台返回的 ServiceId>

License

MIT

1.2.0

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.1.4

4 years ago

1.0.7

4 years ago

1.0.6-alpha.523

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.3.0

4 years ago

0.2.97

4 years ago

0.2.95

4 years ago

0.2.89

4 years ago

0.2.88

4 years ago

0.2.76

4 years ago

0.2.75

4 years ago

0.2.74

4 years ago

0.2.73

4 years ago

0.2.72

4 years ago

0.2.65

4 years ago

0.2.64

4 years ago

0.2.63

4 years ago

0.2.61

4 years ago

0.2.59

4 years ago

0.2.55

4 years ago

0.2.49

4 years ago

0.2.27

4 years ago

0.2.6

4 years ago

0.2.0

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago