1 00:00:00,600 --> 00:00:05,370 Inless video we spoke about the flow that a user will go through as they are creating a survey. 2 00:00:05,400 --> 00:00:09,060 We're now going to talk a little bit about some of the different routes that we're going to set up on 3 00:00:09,060 --> 00:00:14,540 our express server to allow users to create surveys get a list of them and so on. 4 00:00:14,610 --> 00:00:16,830 So let's talk about all those different routes. 5 00:00:17,220 --> 00:00:22,020 Now as we start building all this survey stuff I can definitely tell you that a lot of the backend stuff 6 00:00:22,010 --> 00:00:25,880 that we're going to do is going to be a lot of moving pieces. 7 00:00:25,890 --> 00:00:26,790 Let's put it that way. 8 00:00:26,820 --> 00:00:30,570 I'm not going to say that it's going to be crazy complicated because I think a lot of the code that 9 00:00:30,570 --> 00:00:35,790 we're going to write will be fairly straightforward but there's going to be a lot of different parts 10 00:00:35,790 --> 00:00:40,020 of the puzzle so to speak kind of moving around to make sure that these emails get sent out. 11 00:00:40,320 --> 00:00:46,060 So we're going to do our best to make sure that we kind of isolate one route to work on at a given time. 12 00:00:46,060 --> 00:00:50,250 We will test it until we are really sure that it's worked in the way we expect and I'll move on to the 13 00:00:50,250 --> 00:00:53,280 next one after we finish all three of these routes. 14 00:00:53,280 --> 00:00:57,510 We will then move on to the front end of our application and build out the front end to make sure that 15 00:00:57,510 --> 00:01:00,470 it matches these back end routes we put together. 16 00:01:00,910 --> 00:01:01,250 Okay. 17 00:01:01,260 --> 00:01:04,620 So let's talk about these three routes that we're going to create. 18 00:01:04,710 --> 00:01:11,400 We'll start off with the easiest one up at top so this will be a GET request to API slash service when 19 00:01:11,400 --> 00:01:17,580 the user makes a request to this route really straightforward find all of the surveys that the current 20 00:01:17,580 --> 00:01:19,000 user has created. 21 00:01:19,010 --> 00:01:24,100 And remember when I say current user right here I'm talking about the user who issued this request. 22 00:01:24,270 --> 00:01:28,420 So we'll find all the surveys that they have created and we will return them back to them. 23 00:01:28,560 --> 00:01:33,390 So you can imagine that this first route right here is really all about making sure that we can show 24 00:01:33,390 --> 00:01:37,710 a list of all the surveys that the user has created and the different feedback that they have received 25 00:01:37,710 --> 00:01:39,940 for each one. 26 00:01:39,950 --> 00:01:44,440 Now we're going to skip the second one for just a second and move on to the third one down here. 27 00:01:44,460 --> 00:01:49,220 So the third one will be a POST request to API slash service. 28 00:01:49,440 --> 00:01:54,360 The purpose of this handler will be to handle the case in which a user wants to create a new survey 29 00:01:54,630 --> 00:01:58,660 and have it automatically be e-mailed out to everyone they want. 30 00:01:58,680 --> 00:02:03,540 Now whenever someone makes a POST request to this route we are going to expect that they send along 31 00:02:03,660 --> 00:02:07,580 four different pieces of data with a POST request. 32 00:02:07,590 --> 00:02:10,560 The first is going to be a title property. 33 00:02:10,560 --> 00:02:14,700 Now the title is going to be the title of the survey. 34 00:02:14,730 --> 00:02:20,290 In other words the name for the survey that the user will see when they are in our application. 35 00:02:20,610 --> 00:02:26,400 You might think that the title versus the subject line of the email should be the same but really you 36 00:02:26,400 --> 00:02:32,540 might want to call a title of a survey something like March 22 survey results or something like that 37 00:02:32,550 --> 00:02:38,160 something that has meaning to you as our user and you might not want that to be reflected as the exact 38 00:02:38,160 --> 00:02:43,300 same subject of email which is actually sent out to your end users. 39 00:02:44,310 --> 00:02:44,650 OK. 40 00:02:44,670 --> 00:02:48,350 So we're going have a title which will be kind of the internal name of the survey. 41 00:02:48,480 --> 00:02:54,240 We will have a subject which will be the subject line to show in the email we will have a body property 42 00:02:54,630 --> 00:03:00,750 which will be the text to show in the actual email which will essentially be this text right here right 43 00:03:00,750 --> 00:03:01,460 in the center. 44 00:03:01,470 --> 00:03:05,460 We were hoping you could tell us if you enjoyed our service blah blah blah you know all this kind of 45 00:03:05,460 --> 00:03:05,730 stuff. 46 00:03:05,730 --> 00:03:08,170 So this would be the body of the survey right here. 47 00:03:08,220 --> 00:03:14,140 The actual text to show in the email to prompt the end user to click on one of the two buttons. 48 00:03:14,400 --> 00:03:17,010 And then finally a recipient's property. 49 00:03:17,010 --> 00:03:22,710 Now this one is definitely the most important property the recipient's property and is going to be a 50 00:03:22,710 --> 00:03:25,750 comma separated list of email addresses. 51 00:03:25,980 --> 00:03:30,840 So this will be the list of addresses to send out the e-mail to. 52 00:03:30,840 --> 00:03:38,730 So in total the POST request route for API surveys all about creating a new survey we're going to require 53 00:03:38,730 --> 00:03:41,750 to have these four different properties. 54 00:03:42,270 --> 00:03:42,570 OK. 55 00:03:42,600 --> 00:03:44,490 Now the very last one. 56 00:03:44,610 --> 00:03:50,640 All right here in the middle a POST request to API slash surveys slash WebEx. 57 00:03:50,730 --> 00:03:55,080 So this one is going to be a little bit more challenging to understand until we start to really dive 58 00:03:55,080 --> 00:03:59,800 into some of the implementation with the actual email provider that we're going to use. 59 00:04:00,090 --> 00:04:08,340 So the intent of this route right here is to receive feedback from a user and end user who has received 60 00:04:08,340 --> 00:04:11,030 an e-mail and clicked a link in the survey. 61 00:04:11,220 --> 00:04:16,910 So this would be like if I'm an end user I get this e-mail right here and I click yes right here. 62 00:04:17,040 --> 00:04:20,500 That would be me issuing a piece of feedback. 63 00:04:20,610 --> 00:04:26,660 So we're going to somehow report that through this route right here of a POST request to API surveys 64 00:04:26,660 --> 00:04:28,310 slash Web looks. 65 00:04:28,490 --> 00:04:34,770 Now like I said in the last section we are going to use our e-mail provider to record the actual output 66 00:04:34,830 --> 00:04:36,930 of clicking on a yes or no right here. 67 00:04:36,930 --> 00:04:40,110 That's why we've got this kind of name web hooks in here. 68 00:04:40,140 --> 00:04:42,570 We'll talk about what a web hook is later on. 69 00:04:42,570 --> 00:04:45,470 And again there is a very good reason that we're taking this approach. 70 00:04:45,600 --> 00:04:50,070 And once we start getting over to this route you make sure I'll make sure that you've got a much better 71 00:04:50,070 --> 00:04:52,350 sense of exactly why we're doing it this way. 72 00:04:52,380 --> 00:04:54,330 Just take my word for it right now. 73 00:04:54,330 --> 00:04:59,250 We're going to make sure that the e-mail provider is the one to record the actual click and then they 74 00:04:59,250 --> 00:05:05,430 will tell our express server Hey someone clicked blink or no they did not or whatever it might be. 75 00:05:06,480 --> 00:05:06,870 OK. 76 00:05:06,900 --> 00:05:09,050 So that's pretty much it for our different routes. 77 00:05:09,210 --> 00:05:10,630 So let's take a break right now. 78 00:05:10,650 --> 00:05:16,910 When we come back in the next section we're going to start putting together our post for API slash surveys. 79 00:05:16,920 --> 00:05:21,110 So essentially we're going to handle the case in which a user wants to create a new survey. 80 00:05:21,390 --> 00:05:23,790 So quick break and I'll see you in just a minute.