Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:02,160 --> 00:00:05,970
‫And with that, we're almost done with the theory.
2
00:00:05,970 --> 00:00:14,270
‫Now there's just one more thing left and that is related to how we host our different parts.
3
00:00:14,520 --> 00:00:21,000
‫You know from the big picture that we have three big blocks, the React app, the Node Express app and
4
00:00:21,000 --> 00:00:25,440
‫the MongoDB database and the server that database runs on.
5
00:00:25,440 --> 00:00:30,190
‫Now the question is, where are the different pieces served from?
6
00:00:30,240 --> 00:00:32,200
‫Now we got two main options here,
7
00:00:32,280 --> 00:00:39,330
‫we can have one server, one computer which hosts both our Node API and the React single page application
8
00:00:39,420 --> 00:00:41,520
‫under the same domain,
9
00:00:41,520 --> 00:00:50,070
‫so my mypage.com/ might return our single page application and then under
10
00:00:50,070 --> 00:00:56,220
‫mypage.com/api, we might have the endpoints for that single page application to talk to.
11
00:00:56,580 --> 00:00:59,940
‫The alternative is that we have two separated servers,
12
00:00:59,940 --> 00:01:07,680
‫one very simple server which simply serves our single React.js application HTML page and all the
13
00:01:07,680 --> 00:01:08,790
‫Javascript files
14
00:01:08,790 --> 00:01:17,430
‫that application needs and one server which hosts our API. So if we take a closer look, for the left case
15
00:01:17,430 --> 00:01:23,310
‫that we have one single server, we have a Node Express API which handles incoming requests on that server,
16
00:01:23,430 --> 00:01:25,830
‫for example under /api,
17
00:01:25,830 --> 00:01:33,840
‫any requests targeting these paths might reach our API and requests which are not targeting our API routes
18
00:01:34,050 --> 00:01:37,080
‫would return the React single page application in the end,
19
00:01:37,110 --> 00:01:43,590
‫so these requests would get us a single HTML file and the associated Javascript files that are required
20
00:01:43,590 --> 00:01:47,430
‫to run the React app. Between the React app and the Node API,
21
00:01:47,490 --> 00:01:53,640
‫even though they're running on the same server, we have that separation you learned about, so they don't really know much
22
00:01:53,640 --> 00:01:54,810
‫about each other
23
00:01:54,810 --> 00:01:57,660
‫other than that they run on the same server,
24
00:01:57,660 --> 00:02:04,320
‫data is still exchanged with these Ajax background requests in JSON format.
25
00:02:04,340 --> 00:02:06,250
‫If we have the two separated servers,
26
00:02:06,250 --> 00:02:10,630
‫then we really have two different machines, one which has our Node API on it,
27
00:02:10,710 --> 00:02:18,570
‫our Node Express API and one which is served from that very simple, so-called static host, static because
28
00:02:18,570 --> 00:02:24,000
‫it will be a server which doesn't need to execute any server side code because it is a server that
29
00:02:24,000 --> 00:02:28,740
‫doesn't run any Node or any other programming language application on it,
30
00:02:28,740 --> 00:02:34,160
‫instead it's just a server which returns our HTML file and Javascript files and the CSS files
31
00:02:34,170 --> 00:02:35,150
‫and so on.
32
00:02:35,160 --> 00:02:42,750
‫So therefore we got our two ends served on different servers and data is exchanged in JSON format
33
00:02:42,780 --> 00:02:45,330
‫when we sent these background HTTP requests.
34
00:02:45,390 --> 00:02:47,130
‫So that's always the same,
35
00:02:47,280 --> 00:02:52,110
‫in one case they're just served from the same machine, in the other case from two machines,
36
00:02:52,110 --> 00:02:55,290
‫in both cases we got these logically separated apps.
37
00:02:55,290 --> 00:03:01,590
‫Now regarding the MongoDB database, that always has its own database server but just like
38
00:03:01,620 --> 00:03:07,800
‫the Node server and the React app, this server could be installed on the same physical machine as our
39
00:03:07,800 --> 00:03:14,220
‫Node and maybe also React app runs on or on a separate machine and often you want to use different
40
00:03:14,220 --> 00:03:20,280
‫machines here to make sure that just because you're getting a lot of requests, you're not slowing down
41
00:03:20,280 --> 00:03:24,230
‫on your database requests or database queries and the other way around,
42
00:03:24,240 --> 00:03:30,540
‫so therefore separating the Node Express app and the database server onto two different machines is
43
00:03:30,540 --> 00:03:31,350
‫a good idea.
44
00:03:31,410 --> 00:03:34,090
‫Technically you could run everything on the same machine,
45
00:03:34,140 --> 00:03:37,790
‫you'll always have the same logical separation though.
46
00:03:37,980 --> 00:03:42,730
‫Now actually, there also is a third way which I really don't want to talk too much about though,
47
00:03:42,810 --> 00:03:50,400
‫you could have your Node Express server and not build a REST or GraphQL API there but instead, render
48
00:03:50,450 --> 00:03:57,370
‫HTML pages on the fly, on that server with templating engines like EJS or Pug.
49
00:03:57,450 --> 00:04:03,150
‫If you took my Node.js - The Complete Guide course, you learned about this approach as well.
50
00:04:03,240 --> 00:04:09,450
‫Now you therefore really rendered different HTML pages for different requests on the server and
51
00:04:09,450 --> 00:04:14,660
‫that rendered HTML code is returned. Now to get React into the equation,
52
00:04:14,700 --> 00:04:22,290
‫you could have some parts of these pre-rendered HTML pages which are controlled by React in a widgetlike
53
00:04:22,290 --> 00:04:27,490
‫way, so React only controls parts of the page instead of the entire page.
54
00:04:27,510 --> 00:04:33,800
‫This is possible but it takes away from the great, highly reactive user experience
55
00:04:33,900 --> 00:04:40,440
‫we can build with single page applications. Since we create and return HTML pages from the server
56
00:04:40,440 --> 00:04:42,520
‫for everything the user does,
57
00:04:42,540 --> 00:04:51,060
‫we constantly reload pages, we add a slight delay and we don't have that highly reactive mobile applike
58
00:04:51,060 --> 00:04:54,560
‫feeling we can achieve with single page applications.
59
00:04:54,600 --> 00:04:57,690
‫Therefore this is not the approach we will use here,
60
00:04:57,690 --> 00:05:02,290
‫technically of course though you could build an application with the same technologies, MongoDB
61
00:05:02,310 --> 00:05:09,510
‫Express React and Node, so MERN, with this approach but you would not get the same great user experience
62
00:05:09,810 --> 00:05:15,360
‫and therefore typically when we talk about MERN, we talk about the logically separated ends, no matter if
63
00:05:15,360 --> 00:05:18,130
‫they're served by the same physical machine or not,
64
00:05:18,180 --> 00:05:25,170
‫we don't talk about this approach. Well and with that all out of the way, let's have a look at the very
65
00:05:25,170 --> 00:05:30,200
‫simple first MERN application so that you can see the big picture
66
00:05:30,210 --> 00:05:37,620
‫also in code before we den dive into the different course modules where we will get a refresher on React
67
00:05:37,620 --> 00:05:43,310
‫Node Express and MongoDB and then more importantly, build the different building blocks of our
68
00:05:43,320 --> 00:05:48,240
‫course project which is such a MERN app and then also connect these building blocks.
7932
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.