官术网_书友最值得收藏!

How it works...

The first thing to notice is that we are using all the same development tools for the full stack. This is one of many advantages of using JavaScript for backend development. A single, self-sufficient, full-stack team can develop the frontend application and the BFF service with the same programming language. This can allow for more efficient utilization of team resources.

There are two new standard scripts—start and build. npm start will run the frontend app locally using Node.js as the web server. npm run build will prepare the application for deployment. I used the react-scripts library so as not to clutter the example with a detailed ReactJS build process. This recipe uses a small, canned ReactJS example for the same reason. I wanted an app that was just large enough to have something to deploy. ReactJS is not the focus of this recipe or cookbook. There are volumes already written on ReactJS and similar frameworks.

We are creating an S3 bucket, WebsiteBucket, and configuring it as a website. The stack output displays the WebsiteUrl used to access the SPA. The SPA will be served from a bucket with no need for servers whatsoever. In this context, we can think of S3 as a global web server.

We are using a Serverless plugin for the first time in this recipe. The serverless-spa-deploy plugin will upload the SPA files from the ./build directory after the stack is deployed. Note that we are not explicitly naming the bucket. CloudFormation will generate the name with a random suffix. This is important because bucket names must be globally unique. The plugin infers the generated bucket name. The plugin has sensible defaults that can be customized, such as to change the CacheControl headers for different files. The plugin also empties the bucket, before stack removal.

We will build on this architecture in Chapter 4, Leveraging the Edge of the Cloud.
主站蜘蛛池模板: 台南市| 武隆县| 凤城市| 宁晋县| 绩溪县| 济阳县| 梁山县| 印江| 大城县| 平江县| 奈曼旗| 聂拉木县| 抚顺县| 洛宁县| 萝北县| 松溪县| 长宁区| 石家庄市| 临沧市| 宝丰县| 嘉善县| 策勒县| 黎城县| 洪泽县| 新蔡县| 石嘴山市| 涟水县| 银川市| 麻江县| 秭归县| 望城县| 北京市| 长宁区| 阿拉尔市| 湘潭市| 景泰县| 英超| 乐都县| 长沙市| 民勤县| 任丘市|