- Create the Node.js backend
- Set up Mysql
- Create routes to retrieve all the characters and one character
- Return the information as JSON, so we can use it in React
- Split the application in different components => Layout, Character, App
- The Character component represents each character queried
- The Layout represents the whole app - nav bar, body, footer, etc.
- The App holds the routing information
- Add sorting by height and/or species
RUN in your terminal:
docker run -e MYSQL_ROOT_PASSWORD=password -p 3306:3306 -it mysql:5.6
- In another terminal
mysql -u root -p -h 127.0.0.1
CREATE DATABASE starwars
USE starwars
- Run the following:
CREATE TABLE IF NOT EXISTS `characters` (
id int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
name varchar(255) NOT NULL,
height varchar(255) NOT NULL,
species varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Go into the cloned application:
- Run
yarn
- Run
node server
- Go to Postman/Postwoman
- Make the following requests:
POST
request tohttp://localhost:3000/characters
(example below)
{
"name": "C-3PO",
"height": 167,
"species": "Droid"
}
GET
request tohttp://localhost:3000/characters
GET
request tohttp://localhost:3000/characters/1