1 00:00:00,056 --> 00:00:09,263 [MUSIC] 2 00:00:09,263 --> 00:00:12,134 Hi everyone, Gil here, a JavaScript instructor at Treehouse. 3 00:00:12,134 --> 00:00:15,983 In previous lessons, you learned how to use the Sequelize ORM to 4 00:00:15,983 --> 00:00:20,990 interface with sequel based databases within a Node JS application. 5 00:00:20,990 --> 00:00:24,080 You also learned how to work with the Express Web application framework for 6 00:00:24,080 --> 00:00:26,410 Node to build dynamic web applications. 7 00:00:26,410 --> 00:00:27,220 In this workshop, 8 00:00:27,220 --> 00:00:30,180 you will bring together much of what you've learned about Sequelize and 9 00:00:30,180 --> 00:00:35,060 Express to build a simple CRUD application that is connected to a Sequel database. 10 00:00:35,060 --> 00:00:38,760 You will use the method Sequalize provides to perform CRUD operations within Express 11 00:00:38,760 --> 00:00:43,990 routes using HTTP methods like Get and Post to manage the data and the database. 12 00:00:43,990 --> 00:00:47,890 In addition, you'll work with the sequelize/cli a helpful command line 13 00:00:47,890 --> 00:00:51,170 interface for sequelize to initialize all the configuration code, 14 00:00:51,170 --> 00:00:53,870 folders and helpers needed for the application. 15 00:00:53,870 --> 00:00:58,601 The project you will build and this workshop is a simple blog application, 16 00:00:58,601 --> 00:01:02,055 it's going to have a page that lists all the articles, 17 00:01:02,055 --> 00:01:07,033 a create article page an edit article page as well as a way to delete an article. 18 00:01:07,033 --> 00:01:10,665 So we're essentially performing all the CRUD or create, read, update and 19 00:01:10,665 --> 00:01:13,110 delete operations using a web interface. 20 00:01:13,110 --> 00:01:16,360 And you'll be able to apply what you learn while building this project to just about 21 00:01:16,360 --> 00:01:19,700 any node or express and sequel application you create moving forward. 22 00:01:20,940 --> 00:01:24,360 To get started and code along with me, download the project files with this video 23 00:01:24,360 --> 00:01:26,780 and open the starter files in your favorite text editor. 24 00:01:26,780 --> 00:01:28,570 I'm using Visual Studio Code. 25 00:01:28,570 --> 00:01:33,070 Once you open the starter files, run the command MPM install in your terminal or 26 00:01:33,070 --> 00:01:35,640 console to install all the project dependencies. 27 00:01:37,090 --> 00:01:39,400 After the dependencies finished downloading and 28 00:01:39,400 --> 00:01:44,000 installing, run, MPM start to start the application. 29 00:01:44,000 --> 00:01:47,613 And you can view the app in the browser on localhost port 3000. 30 00:01:47,613 --> 00:01:51,690 So this is the beginning state of the blog application. 31 00:01:51,690 --> 00:01:54,440 To get it started, I used the express application 32 00:01:54,440 --> 00:01:57,920 generator tool to create the express app which I then modified. 33 00:01:57,920 --> 00:02:02,350 The express generator is a command line tool that makes it easy to start new apps. 34 00:02:02,350 --> 00:02:05,290 It sets up much of the boolar plain code needed to build an express 35 00:02:05,290 --> 00:02:07,030 app like starting a new server instance, 36 00:02:07,030 --> 00:02:10,390 configuring a view engines, setting up air handling and more. 37 00:02:10,390 --> 00:02:14,428 The structure of the generated express application contains folders such as bin, 38 00:02:14,428 --> 00:02:18,476 public, routes and views which you will learn about as you build the application. 39 00:02:18,476 --> 00:02:21,166 You're can learn more about the express generator tool and 40 00:02:21,166 --> 00:02:24,260 its helpful command options in the teachers notes with this video. 41 00:02:24,260 --> 00:02:26,574 The focus of this workshop in on Sequelize, 42 00:02:26,574 --> 00:02:30,740 so we're going to work on connecting to a data base from the express app and 43 00:02:30,740 --> 00:02:33,920 write all the data base calls within the route handler functions. 44 00:02:33,920 --> 00:02:37,880 I've already included all the view templates inside the views folder, and 45 00:02:37,880 --> 00:02:41,390 starter code to handle the routes inside the routes folder. 46 00:02:41,390 --> 00:02:44,200 For example, the app uses the pug 47 00:02:44,200 --> 00:02:47,100 templating engine to generate all the views. 48 00:02:47,100 --> 00:02:52,170 And the articles.js file inside the routes folder, holds all the routes to create, 49 00:02:52,170 --> 00:02:54,960 read, update and delete articles in the app. 50 00:02:54,960 --> 00:03:00,280 Both the index and articles routes are imported into app.js, 51 00:03:00,280 --> 00:03:03,985 then passed to the Express app via these app.use methods. 52 00:03:03,985 --> 00:03:08,860 We'll add more inside the route handlers as we implement the database code. 53 00:03:08,860 --> 00:03:10,898 Before moving on to the next step, go ahead and 54 00:03:10,898 --> 00:03:13,107 familiarize yourself with the routes and views. 55 00:03:13,107 --> 00:03:15,458 Once you're ready, you'll start by setting up and 56 00:03:15,458 --> 00:03:17,580 connecting to a sequel lite database. 57 00:03:17,580 --> 00:03:20,970 To be successful in this workshop that you should be familiar with using 58 00:03:20,970 --> 00:03:25,000 the Sequelize ORM as well as the Express framework and 59 00:03:25,000 --> 00:03:28,390 the async await syntax for working with promises. 60 00:03:28,390 --> 00:03:31,888 So be sure to review the teachers notes with this video if you need a refresher on 61 00:03:31,888 --> 00:03:32,848 any of these topics.