This article shows how to initialize a Nuxt.js application using the Serverless Framework

What is Serverless Framework

Serverless Framework is a very popular Serverless application Framework in the industry. Through close cooperation with many first-class cloud providers such as Tencent Cloud and AWS, it provides the majority of developers with a service free development experience to write and deploy code without caring about the underlying infrastructure.

Serverless Framework also provides resource management, automatic scaling, statistical analysis and other capabilities, so that the majority of developers can save operation and maintenance costs, truly “pay by volume” at the same time, but also do not need to spend energy to deal with log collection, abnormal statistics and other tasks.

Serverless Framework works closely with Tencent Cloud through CLI tools to provide Chinese users with a complete solution based on Serverless Components. It covers the whole life cycle of unserved application coding, testing, deployment, etc., and is more in line with the usage scenarios and habits of Chinese users

  • Serverless Framework in Chinese: www.serverless.com/cn/framewor…

1. Install Serverless Framework

Reference site: cloud.tencent.com/document/pr…

I’m using setup here

npm install -g serverless
Copy the code

2. Use mkdir to create a project directory and enter it

mkdir express-proj
cd express-proj
Copy the code

3. Run serverless in this directory and the following appears

Serverless // Serverless: The serverless project is not currently detected. Do you want to create a new project? (Y/n)Copy the code

Here you choose the template you want to create, and here I’ll create next. Js project

Fill in the project name here, next-Proj

Wait until the installation is complete

Deploy upload If you want to deploy upload, you need to use wechat scan code and authorize it

Or use SLS deploy for uploading at a later date. (SLS is short for Serverless)

sls deploy 
Copy the code

After the deployment is successful, you can view it in the Tencent Cloud Serverless application

Your directory should look like this after installation

Here we open the package.json file

Basically the same as the normal nuxt.js framework

Run NPM run dev to start the local development environment

npm run dev
Copy the code

You can be happy with the code

  • The online access address of this demo

service-jrpny2p2-1255469424.gz.apigw.tencentcs.com/release/


SLS command

See SLS commands for a quick start using SLS help

  • Directly enter “serverless” (or abbreviated “SLS “) for project initialization

link

  • The product documentation: cloud.tencent.com/document/pr…
  • Control panel: serverless.cloud.tencent.com/
  • Q&a community: github.com/serverless/…

The command

  • You can execute commands through “serverless” or simply “SLS”
  • Use “serverless [command] –help” to obtain detailed help information
  • Init initializes the new project from the template
  • Deploy Deploys applications to the cloud
  • Info Displays application details
  • Dev starts debug mode
  • Logs Displays application logs
  • Remove Remove an application.
  • The credentials manage global authorization information
  • Registry displays information about components and templates in the application center
  • Publish components or templates to the application center
  • Bind Role reassigns the required permissions to the current user to use Serverless

Serverless. Yml File contents