Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to migrate Express to function calculation

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to migrate Express to function calculation". The explanation content in this article is simple and clear, easy to learn and understand. Please follow the idea of Xiaobian and go deep into it slowly to study and learn "how to migrate Express to function calculation" together.

First, let me introduce some of the more important concepts that appear in this article:

Function Compute: Function Compute is an event-driven service. Through function calculation, users do not need to manage the operation of the server, just write code and upload it. Function calculations prepare compute resources and run user code in an Auto Scaling fashion, while users pay only for the resources consumed by the actual code run.

Fun: Fun is a tool to support Serverless application deployment, helping you to easily manage resources such as function calculations, API gateways, logging services, and more. It assists you with development, build, and deployment through a resource profile (template.yml).

Note: The techniques described in this article require Fun version 3.6.3 or greater.

background information

Express is a minimalist, flexible Web application development framework based on the Node.js platform that provides a powerful set of features to help you create Web and mobile applications.

Step 1: Prepare the environment

The method described in this article does not need to install Docker, just install Fun, the easiest way is to download the executable binary file directly.

Install Fun on the machine.

Run fun --version to check if the installation was successful.

Step 2: Migrate the application

Execute the following command to create an Express project.

npx express-generator

Execute the following command to enter the sample project you just created or your project.

cd

Execute the following command to install dependencies.

npm install

Execute the following command to run the project.

MacOS, Linux platform running projects:

DEBUG=myapp:* npm start

Windows platform running projects:

set DEBUG=myapp:* & npm start

Execute the command fun deploy -y to deploy the project to the function evaluation.

Fun automatically enters the deployment process.

$fun deploy -y current folder is not a fun project. Generating /Users/txd123/Desktop/Express/bootstrap... Generating template.yml... Generate Fun project successfully! ========= Fun will use 'fun deploy' to deploy your application to Function Compute! ========= using region: cn-qingdao using accountId: ***********3743 using accessKeyId: ***********Ptgk using timeout: 60 Collecting your services information, in order to caculate devlopment changes... Resources Changes(Beta version! Only FC resources changes will be displayed): ... ... ... ... trigger httpTrigger deploy success function Express deploy success service Express deploy success Detect 'DomainName:Auto' of custom domain 'Domain' Request a new temporary domain ... The assigned temporary domain is 15795585-XXX.test.functioncompute.com,expired at 2020-04-12 10:46:25, limited by 1000 per day. Waiting for custom domain Domain to be deployed... custom domain Domain deploy success

After deployment, you can see from the log of successful deployment that the function calculation generates a temporary domain name for you, and you can directly access the application just deployed through this temporary domain name.

Thank you for reading, the above is "how to migrate Express to function calculation" content, after the study of this article, I believe we have a deeper understanding of how to migrate Express to function calculation this problem, the specific use of the situation also needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report