So, in order to test it, I can run npm run dev here, running that dev script I set up
before, which will start that server, and we can start sending requests to that server,
specifically to slash users, and then there to slash signup, with some user data attached
to signup a user.
Now when it comes to testing REST APIs, there are different ways of doing that, different
tools you can use.
One fairly popular, easy-to-use tool is Postman, which you can use for free.
You can also pay for stuff there, but you can download it for free and use it for free
regarding what we're planning to do here.
So you can download Postman from their site, you don't need to pay anything for it.
And once you did that, you can start this Postman tool, you might need to click through
a couple of windows, but ultimately you should be able to get to this API testing part without
paying anything and actually also without creating an account.
And here you can then send a new request, a POST request, for example, because that's
what I'm expecting here.
A POST request to slash users slash signup, so to localhost 3000, that's where the app
is being hosted right now during development, slash users slash signup, and then add a body
by clicking on body here, choose raw, and then JSON, because our API here is expecting
to get some JSON data.
This line here in app.js will make sure that data in the JSON format will be parsed and
will be accessible in the different parts of this application.
And then here for signing up, we will need to add an email and a password field to our
request body in the JSON format.
So here I'll add a JSON object with an email field between double quotes and then test
at example.com, then separate it by a comma in a new line, a password field between double
quotes, and then test123abc, something like this.
If I now click send here, I'm getting back a success response, user created successfully,
that's looking good.
I get back some user details like the ID that was assigned to it automatically.
And if you go back to the project, we should find a database.sqlite file in there which
will store that data.
Now you can't view that data like this here, it's pretty cryptic as you can tell, but it
seems to work.
And you can install extra extensions like the SQLite viewer extension to actually view
your database data.
This extension doesn't allow you to change it, but you can view it at least.
So with installing that, now I can browse that database and I see, yes, this data was
stored.
Though, I'll also highlight right away that the password was stored in plain text, which
is not a good idea, because if that database would ever get compromised, hackers would
have full access to the unencrypted password of your user.
And that would allow them to access the user data in your application, and since users
tend to reuse passwords across multiple apps, they could also try to get access to different
applications.
So you'd never want to store data like this.
And that's therefore something I'll have to fix here.
Now maybe, if you followed along on your own, for you, Cursor suggested a different code
which does encrypt the data, which does hash the password, but for me here, it didn't
do that, so that's something I'll now tell Cursor to do.