netlify 部署vue
介绍 (Introduction)
It is a good software engineering practice to separate portions of your code function to work independently of other parts. Since your codes are made up of functions basically, serverless functions allow you to deploy those functions without the complexity of managing a server to run them.
将代码功能的各个部分分开以独立于其他部分工作是一种很好的软件工程实践。 由于代码基本上由功能组成,因此无服务器功能使您可以部署这些功能,而无需管理服务器来运行它们。
In this tutorial, we will be learning what serverless functions are, how to write them, and how to deploy them on Netlify in minutes. We will also touch up on other uses of serverless functions.
在本教程中,我们将在几分钟内学习什么是无服务器功能,如何编写它们以及如何在Netlify上部署它们。 我们还将探讨无服务器功能的其他用途。
什么是无服务器功能? (What are Serverless Functions?)
A serverless function is a function hosted on a cloud infrastructure and performs a single purpose. It is very similar to every other function you write as long as it has its own dependencies and can run on its own. It is serverless because it takes off the stress of server maintenance and scaling the function from you.
无服务器功能是托管在云基础架构上的功能,可以执行一个目的。 它与您编写的所有其他函数非常相似,只要它具有自己的依赖关系并且可以自己运行即可。 它是无服务器的,因为它减轻了服务器维护和扩展功能的压力。
Netlify has made it very easy to write any backend task and deploy it independently or alongside your project in simple steps. Your functions can also be deployed by a simple git push
command if linked with your GitHub repository. These functions are called Netlify Functions.
Netlify使编写任何后端任务并轻松地将其独立部署或与您的项目一起部署变得非常容易。 如果与GitHub存储库链接,还可以通过简单的git push
命令部署您的功能。 这些功能称为Netlify功能 。
Serverless functions work just like your API endpoint
无服务器功能就像您的API终结点一样工作
让我们构建我们的无服务器功能 (Let’s Build our Serverless Function)
创建一个项目文件夹 (Create a project folder)
Create an empty folder either manually or by running mkdir custom-netlify-functions
. Use any name you feel like. Here I'm using 'custom-netlify-functions'.
手动或通过运行mkdir custom-netlify-functions
创建一个空文件夹。 使用您喜欢的任何名称。 在这里,我正在使用“ custom-netlify-functions”。