This script is designed to facilitate the process of populating the database with products for use in my REST-API. Specifically crafted for testing and development purposes, it enables users to quickly load predefined data into their database.
The script populates the database with fitness products, utilized in the Catalog page of my Fitness Web App.
Before using the script, ensure the following requirements are met:
- Node.js is installed on your machine.
- Proper setup of the REST-API.
- Installed dependencies.
-
Clone the repository to your local machine:
git clone <repository-url> cd ./scripts
-
Install dependencies:
npm install
Before running the script, make sure to set the following environment variables:
- ADMIN: This variable should contain the email address of the admin user.
- PRODUCTION_URL: This variable should be set to the URL of the production API endpoint where you want to preload the database with items.
- LOCAL_URL: This variable should be set to the URL of the local API endpoint where you want to preload the database with items.
Example:
export ADMIN="[email protected]"
export PRODUCTION_URL="https://production.web/api/v1/catalog"
export LOCAL_URL="http://localhost:5000/api/v1/catalog"To run the script in different environments, you can use the following npm scripts:
- For loading the database in production environment:
npm run loadDb:prod- For loading the database in local environment:
npm run loadDb- Ensure that you have set up the REST-API first.
- Run the npm command in the correct directory.