sls init http-demo
. http-demo├── serverless.yml # Configuration file├── package.json # Dependency file├── scf_bootstrap # Project bootstrap file└── index.js # Service function
scf_bootstrap is the project bootstrap file. For the specific writing rules, please see Bootstrap File Description.serverless.yml to view the configuration information.
You only need to add the type parameter in yml to specify the function type and deploy the web function.type parameter is not entered, the function will be an event function by default.scf_bootstrap bootstrap file in the local code, you can specify the entryFile parameter in yml to specify the entry function, and the component will generate a default scf_bootstrap file for you to complete the deployment based on the runtime language. After the deployment is completed, you need to modify the content of the scf_bootstrap file in the SCF console according to the actual needs of your project.yml file:component: scfname: httpinputs:src:src: ./exclude:- .env# Specify web type as the function typetype: webname: web-functionregion: ap-guangzhouruntime: Nodejs12.16# For Node.js, you can enable automatic dependency installationinstallDependency: trueevents:- apigw:parameters:protocols:- http- httpsenvironment: releaseendpoints:- path: /method: ANY
sls deploy to complete the service deployment. Below is a sample:$ sls deployserverless ⚡componentsAction: "deploy" - Stage: "dev" - App: "http" - Name: "http"type: webfunctionName: web-functiondescription: This is a function in http applicationnamespace: defaultruntime: Nodejs12.16handler:memorySize: 128lastVersion: $LATESTtraffic: 1triggers:-NeedCreate: truecreated: trueserviceId: service-xxxxxxserviceName: serverlesssubDomain: service-xxxxxx.cd.apigw.tencentcs.comprotocols: http&httpsenvironment: releaseapiList:-path: /method: ANYapiName: indexcreated: trueauthType: NONEbusinessType: NORMALisBase64Encoded: falseapiId: api-xxxxxxinternalDomain:url: https://service-xxxx.cd.apigw.tencentcs.com/release/18s › http › executed successfully
$ sls logserverless ⚡componentsAction: "log" - Stage: "dev" - App: "http" - Name: "http"-requestId: xxxxxretryNum: 0startTime: 1624262955432memoryUsage: 0.00duration: 0message:""""""-requestId: xxxxxretryNum: 0startTime: 1624262955432memoryUsage: 0.00duration: 0message:""""""

curl https://service-xxx.cd.apigw.tencentcs.com/release/
sls remove
Feedback