This project is a service that integrates with the Wildberries API to manage and export tariff data into Google Sheets on a scheduled basis. The service is built using Node.js, with a PostgreSQL database and includes a cron job to regularly update the data.
- Features
- Tech Stack
- Installation
- Environment Variables
- Running the Application
- Scheduling Cron Jobs
- Usage
- Contributing
- Wildberries Tariff Data: Fetches tariff data from the Wildberries API.
- Google Sheets Export: Exports data to a Google Sheets document daily.
- Automated Scheduling: Uses cron jobs to perform daily data updates.
- Database: Stores warehouse and tariff data in a PostgreSQL database.
- Node.js - Server runtime
- Express - Web server framework
- PostgreSQL - Database for data persistence
- Google Sheets API - For exporting data to Google Sheets
- node-cron - For scheduling tasks
-
Clone the Repository:
git clone https://github.com/reseldor/wb-mvp.git cd wb-mvp
-
Install Dependencies:
npm i
-
Setup PostgreSQL Database:
- Ensure PostgreSQL is installed and running.
- Create a new database, e.g., for example with name
wb_mvp_db
. - Run any database migrations if required to set up the schema.
-
Google Service Account Setup:
- Create a Google Cloud project and enable the Google Sheets API.
- Generate a service account and download the (for example file name changed on
secrets.json
) file, which should be placed in the root of the project.
Create a .env
file in the root of your project with the following variables:
APP_PORT=3000
DB_HOST=localhost
DB_PORT=5432
DB_USER=your_db_user
DB_PASSWORD=your_db_password
DB_NAME=wb_mvp_db
GOOGLE_APPLICATION_CREDENTIALS=./secrets.json
Start the server with:
npm run dev
The server should now be running on the port specified in .env.
A cron job is scheduled to fetch and update tariff data every day (for example at 10:50 AM Moscow time). The job runs automatically when the server starts.
The service provides an endpoint to fetch data and export it to Google Sheets automatically. To modify settings or add more sheets, update the configuration accordingly.
- Fork the repository.
- Create a new branch for your feature (
git checkout -b feature-name
). - Commit your changes (
git commit -m 'Add new feature'
). - Push to the branch (
git push origin feature-name
). - Open a Pull Request.