From the course: Node.js: Securing RESTful APIs

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Add the handlers for registration

Add the handlers for registration

From the course: Node.js: Securing RESTful APIs

Start my 1-month free trial

Add the handlers for registration

- [Instructor] Okay, so the next function that we need to create is the function for registering new users. So let's go ahead and keep working on this. So let's do an export of a function which we'll call register. And then this function takes two arguments so a request and a response. And then inside of that function, we'll create first a variable that we'll call newUser. And this function will pass a new user, so remember, we've created a variable here which basically adds the model user and passes the schema that we created earlier and we're going to use this to create a new user. Like so. Leveraging what we've created up there. And we'll pass from the request what is in the body. So remember, when we make transactions with Postman here, in the body, we're passing the data to create a new user and this is what will be in the body of the request which is here. So now we'll have the information for the new user…

Contents