API Documentation: https://plantbase-be.onrender.com/
A Node.js and Express backend for the PlantBase application, providing RESTful APIs for user authentication, plant management, care scheduling, and tasks using Supabase Auth and PostgreSQL.
- Tech Stack
- Features
- Prerequisites
- Environment Variables
- Installation
- Database Setup & Seeding
- Running the Application
- Testing
- API Documentation
- Contributing
- Runtime: Node.js (TypeScript)
- Web Framework: Express
- Database: PostgreSQL (pg)
- Authentication: Supabase Auth
- Seeding & Migrations: Custom SQL + pg-format
- Testing: Jest + Supertest
- Supabase Auth for signup/login (email/password)
- CRUD operations for plants
- Care schedule management (water, fertilise, prune tasks)
- Task completion/advancement logic
- Profile management and user-specific endpoints
- Error handling with custom handlers (404, 400, 403, 500)
- Node.js v16 or higher
- PostgreSQL v12 or higher
- A Supabase project (used for authentication)
Create .env.development and .env.test in the project root with the following variables:
PGDATABASE=<your_database_name>
SUPABASE_URL=<your_supabase_url>
SUPABASE_ANON_KEY=<your_supabase_anon_key>
SUPABASE_SERVICE_ROLE_KEY=<your_supabase_service_role_key>-
Clone the repository:
git clone https://github.com/Emiltps/plantBase-Backend.git cd plantBase-Backend -
Install dependencies:
npm install
-
Development Mode
The default scripts in
package.jsontarget production builds. For a faster development cycle, add a development script:"scripts": { "dev": "ts-node-dev --respawn --transpile-only ./bin/www.ts", // ... existing scripts }
Then run:
npm run dev
-
For production start:
npm start
# Create development and test databases
npm run setup-dbs
# Seed the development database with sample data
npm run seed-dev# Start the server in development mode (using ts-node)
npm start# Run unit and integration tests
npm testInteractive API docs are available at:
https://plantbase-be.onrender.com/