Skip to main content

Posts

Showing posts with the label study notes

Authentication Project: Secret Page App Part Two (Login/Logout)

Login Routes Step One: Add login route For login, we need to write a "/login" route to render to the login page. At the same time, we need to create login page in the "view" folder. Step Two: Set up the local strategy Then, we need to set up the local strategy to be "user authenticate". Step Three: Write post route and add middle-ware Inside the app.post, we pass in "passport.authenticate", which is a middle-ware. It allows codes that run before our final route call back. When app gets a post request to "/login", it's going to run this code immediately.  Step Four: Run the app We run the app and can see the login form. Then, for every page, we add three links: sign up, login, and logout. So the homepage will look like this: Logout Routes  Logout routes are very simple. We need to create a "/logout" route which will log user out and redirect to the...

Seven RESTful Routes You Should Know!

I have been followed the course to develop several app projects. They all follow the RESTful route pattern. Today, I learned many key points about RESTful and would like to share my study note here. What Is REST? REST stands for representational state transfer. I don't know what does this mean, but it is not important right now. You just need to know that REST is just a pattern for defining our routes. What's The Point Of REST? The important things for us is to define what REST is. REST is a way of mapping HTTP routes and CRUD functionality together. By the way CRUD stands for Create, Read, Update, and Destroy. The point of REST is that we don't do whatever we want. Instead, we follow a pattern. It is also more reliable so that if we are interacting with a restful API, it follows a particular pattern. Seven RESTful Routes The course lists the seven route table. It just acts as a pattern that we can fill in the blanks when we develop our own App. screen...