This Example will show you how to make a REST API using Express.js and MySQL.
The database of the example contains two tables: book and user. The user will be used to authorize the REST API users. So, in the exercise you will build a login system, so that the credentials will be checked based on the user.
The book -table has these fields:
It is important that the username is UNIQUE, so that two users can not have the same username. It would have been possible to make the username to be the primary key and remove the id_user. But nowadays using this kind of id's as the primary key is very popular way.
Also it is important that the length of the password field is enough long, because in the example the password will be hashed using bcrypt and nowadays the hash is 60 bytes long.