This is Node/Express project for a Harry Potter API with data stored in a PlanetScale MySQL database.
Clone the repository.
git clone https://github.com/jamesqquick/node-express-planetscale-and-harry-potter
Then, install the dependencies.
npm install
Then, copy the .env.example
file into a .env
file and populate the following properties.
- DB_USER
- DB_PASSWORD
- DB_HOST
- DB_DATABASE
If you need a MySQL database to work with, you can quickly set one up in PlanetScale. After you create your database, you can create a new password to get the necessary credentials for your environment variables.
Next, run the seed.js
script to create your tables and populate them with Harry Potter data.
npm run seed
If you like to automatically create a PlanetScale database, seed it and configure the connectionn string in one step, execute the following command and follow the instructions on screen:
cd .pscale/cli-helper-scripts
./create-database-and-seed.sh
Lastly, run the application.
npm run dev