Welcome back.
In this video, let's go ahead to create some demo route.
And after that, we are going to refactor it to use the MVC design pattern.
So inside the server here are root.
And for this particular application, we are going to have two or three routes based on our model.
So the first one going to be the users root and after users root.
We need the account creation root and after that we need the transaction root.
So here we go.
So for users root, let's have the HTTP method.
The first one going to be the post method and the endpoint going to be API for Slack version one for
Slack users.
All right.
So let's go ahead and create that one.
So going to be app dot posts and then the endpoint going to be as API for slash version one for us slash
users and here goes our callback function and let's make use of async await.
We have our request and then response and I'm going to use a root function.
So here let's bring in, try and catch, let's send some static message to the user by seeing
root.
So the first endpoint here going to be as register.
So here are going to be as register perfect.
So now we got done with the first one.
The second one is going to be the log in.
So I'll copy and change this one to log in.
And the last endpoint here is going to be as log in and here we're going to be as log in root and inside
the catch, let's send the error as error.
So let's copy this one and let's paste it here.
So now we have the two endpoint here.
The next endpoint is going to be the gate or user's endpoint.
But for this particular application, we are going to see all the users unless the admin.
So you can maintain if we want to see all users in your application, you can go ahead and create an
endpoint for that.
So what I want to create right now is going to be the profile.
So here we're going to be as users and then the last endpoint is going to be as pull file.
All right.
So here, let's change this one to profile.
Let's add the dynamic ID here.
So you're going to be asked for a slash ID, so I will show you how we're going to ignore using the
ID by.
Instead, we are going to get the user from the request object and I'll show you as we move on.
So here is going to be as profile.
And after this one, let's go ahead and then create one endpoint.
So here are going to be get request.
Sorry, guys, and for this going to be the delete endpoint so API uses and then we add the ID here
as colon ID.
I forgot to bring the ID here also.
Great.
So now this is going to be as delete endpoint.
So here is going to be forward slash colon ID and you're going to be as delete endpoint or delete root.
And last endpoint you're going to create is for updating.
So you're going to be as put and for updating to we need an ID so users for its last colon ID and here
are going to be as update route.
So the HTTP method here is put endpoint.
So now we have these dummy endpoints for users.
So what about the account?
The process is the same.
This account is a project that we are going to create to keep track of expenses and income for that
particular project.
So here, the endpoint going to be the same thing.
So here are going to be post API users and then here it's going to be as account.
And here, let's change the endpoint from this one to account.
Perfect.
So now when I be asked create account root.
So let's go ahead and then copy this one.
And down here let's paste.
And let's collapse this one.
So here going to be as get a particular account we're going to be as guests and then forward slash column
ID and we're going to be forwards last column ID and you're going to be as.
And for this, the endpoint going to be the same.
But here the HTTP method that differs is going to be as delete.
So here are going to be as delete.
Account root and after deleting you also want to update.
So let me collapse this one and now here are going to be as puts requests for updating it and the same
endpoint we need the ID so here are going to be as put method and the message here is going to be as
an update account root.
So the next endpoint here is going to be the transaction endpoint.
So let's paste that one and the first one going to be post requests and here is going to be transactions,
right?
And then let's remove this one transactions and let's remove the ID and here is going to be as create
transaction.
Then after creating, we also want to fetch all transactions is going to be as gates and then transactions
change this one to get and then here are going to be as get transactions.
So let's copy this one and down here let's pay six and here we want to have a single transaction.
So going to be as colon ID and here is going to be as colon ID and here get transaction single.
And after this one, let's go ahead and then let's also create the delete endpoint.
So here are going to be delete and I would need the same you are or endpoint.
So here I would change this one to delete and they're going to be as delete transaction.
And if you want to update, you will be as put and here is going to be put here going to be as an update
transaction.
All right.
So in case we have some behind the endpoint, we will come back and fix it.
So you can see how our server file is getting clumsy or clustered.
So always the server file responsibility is to start our server.
All the business logic must not be on the server file.
So the next video, let's go ahead and then refactor this particular code to use the routing in experts.