Skip to content
/ midway Public
forked from midwayjs/midway

🍔 A Node.js Serverless Framework for front-end/full-stack developers. Build the application for next decade. Works on AWS, Aliyun, Tencent-Cloud and traditional VM/Container. Super easy integrate with React and Vue. 🌈

License

Notifications You must be signed in to change notification settings

zx119/midway

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Midway Faas

Getting started

Serverless CLI v1.26.1+. You can get it by running:

npm i -g serverless

Example

You can install the following example:

For Aliyun Fc

$ serverless install --url https://github.com/midwayjs/midway-faas/tree/development/packages/serverless-function-examples/aliyun

For Tencent SCF

$ serverless install --url https://github.com/midwayjs/midway-faas/tree/development/packages/serverless-function-examples/scf

Bootstrap

Install npm dependencies.

$ npm i

Usage

Local invoke & debug

serverless invoke -f index

serverless invoke -f index --debug
option explain
-f / --function funcName Specifies the function name to call
--debug=debugPort? Enable step debugging and specifies debug port,default port is 9229

package to zip file

serverless package
option explain
--package Specify the package file(zip) address, e.g. --package=dist
--npm=npmName Specify the npm mirror, e.g. --npm=cnpm
--skipZip Package result does not generate zip package

deploy to online

serverless deploy

Support all package options.

for aliyun

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

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

For Tencent SCF

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

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

此时需要修改 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>

About

🍔 A Node.js Serverless Framework for front-end/full-stack developers. Build the application for next decade. Works on AWS, Aliyun, Tencent-Cloud and traditional VM/Container. Super easy integrate with React and Vue. 🌈

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 98.2%
  • JavaScript 1.3%
  • Shell 0.5%