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

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.
主站蜘蛛池模板: 湟源县| 兴和县| 股票| 连山| 长阳| 宝兴县| 兴国县| 阜宁县| 商城县| 城市| 平邑县| 都匀市| 滨州市| 湘潭县| 桑植县| 赣榆县| 上思县| 青河县| 河池市| 原阳县| 庆城县| 竹溪县| 新沂市| 朝阳区| 汕尾市| 平江县| 洛宁县| 颍上县| 寿阳县| 澄城县| 临沂市| 新疆| 安徽省| 扎兰屯市| 赫章县| 鄂伦春自治旗| 白山市| 元江| 武乡县| 焦作市| 紫金县|