So, our application has a couple of requirements and therefore we got a couple of suggestions
here by ChatGPT regarding routes and files and code we might need.
And I'll use CursorComposer to now generate some of that code and some of these files.
And I'll use this full screen mode here.
Now as I mentioned before, earlier in the course, it is typically a good idea to break
up problems into multiple steps.
So I won't put my entire app description here into one prompt and send it to Cursor.
It might work, I might get a decent result, but I improve my chances by splitting up the
problem of building the entire app into multiple smaller problems.
And the first problem, if you want to call it like this, would be user registration and
login for me.
And that's actually quite a big problem.
We might even need to split up that.
But let's give it a try.
So I'll say this REST API needs user authentication.
Users must be able to register, sign up, and log in.
Don't add any JWT code or anything like that, just generate a user model without using classes
because I don't want to use object-oriented programming here.
In the models folder, to give it some hint where it should store that file and code.
Also generate sign up and log in routes, e.g. slash users sign up in the routes folder.
Last but not least, add the code for linking route and model to a user's controller folder
or controller's folder because in my project I got a folder named controllers.
Don't add any code for storing user data in a database yet because we'll do that later
in a second step.
So that's my first instruction.
Might be too complex, might be too simple.
Let's simply give it a try.
I'll send it to cursor and we'll see what that gives us.
Well, it now created, I already saw that, a user object as it seems.
I want it to have some individual functions, but we can change this.
And in general, it generates a bunch of files here, which is good, makes sense.
It generates a user.js file in the models folder.
In there it has an object with two methods.
I want it to have two separate functions, but I didn't clearly specify that.
So we can change this.
We can also tell it to change that.
And then it got the routes here with the sign up and log in routes.
It calls or it points at some functions in the user's controller.
The user's controller then is a file which also has an object exported with methods.
And then in app.js, it brings in those user's routes by using the user's prefix.
In general, that's not looking too bad.
It also adds this JSON body parser middleware here, which will make sure that requests sent
to that API will be parsed by the express framework and any data attached to the request
body will be made available for easy access in our code.
So that's not too bad, but there are a couple of things I don't like regarding these suggestions.