WEBVTT 0 00:00.490 --> 00:06.460 So now that we've created the data in our database the next step is to create our server. 1 00:06.790 --> 00:09.840 So we're going back from database to server to client. 2 00:10.210 --> 00:14.760 So in order to do this there's a number of steps which are pretty much boilerplate. 3 00:14.770 --> 00:19.750 It's what you're going to do every time when you set up a new server that uses MongoDB. 4 00:19.780 --> 00:22.090 And we've really done it plenty of times before 5 00:22.150 --> 00:25.410 so I'm going to set this to you as a challenge. 6 00:25.430 --> 00:31.090 So the first thing you have to do is to create a new directory called Wiki-API and then we're going 7 00:31.090 --> 00:39.430 to initialize NPM and install 4 packages: body-parser, mongoose, ejs and express. And then we're 8 00:39.430 --> 00:46.600 going to create a new file called app.js and inside app.js we're going to add our server code. 9 00:46.770 --> 00:52.810 So that includes requiring all those modules that we installed and initializing express and setting 10 00:52.810 --> 00:53.710 body-parser up. 11 00:53.950 --> 00:56.560 Now this is something that you need to do every single time. 12 00:56.680 --> 01:02.590 And if you prefer instead of writing it all now you can also go to that repository at github.com 13 01:02.890 --> 01:04.780 /londonappbrewery/ 14 01:04.780 --> 01:11.770 Build-Your-Own-RESTful-API and then if you scroll down you can see that there's some service starting 15 01:11.770 --> 01:18.450 code that I have put there for you which you can copy and paste into your app.js. 16 01:18.700 --> 01:23.260 Now alternatively some students prefer to get extra practice and they try and write it all out. 17 01:23.350 --> 01:27.000 So it's completely up to you which method you want to go down. 18 01:27.160 --> 01:34.000 And once you've set up your server then the next step is to setup MongoDB and our database name as 19 01:34.030 --> 01:40.180 you remember is called wikiDB and the collection that it contains is called articles and all the 20 01:40.180 --> 01:48.590 documents in the article collection has two fields: title and content. So using all of that information 21 01:48.650 --> 01:56.090 you should be able to set up a connection with MongoDB and be able to create the models that you 22 01:56.090 --> 02:02.960 need with Mongoose and be able to set it up. So give that a go and if you get stuck or if you have any 23 02:02.960 --> 02:07.880 problems head back over here and I'll walk you through the entire process.