{"id":31618072,"url":"https://github.com/yanchikfox/clothingshop-api","last_synced_at":"2026-04-05T21:06:18.478Z","repository":{"id":317885544,"uuid":"1062814140","full_name":"YanchikFox/ClothingShop-API","owner":"YanchikFox","description":"Node.js + Express REST API with PostgreSQL, JWT auth, catalogue, categories, and cart.","archived":false,"fork":false,"pushed_at":"2025-10-03T16:48:38.000Z","size":70,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-03T18:17:59.424Z","etag":null,"topics":["docker-compose","express","jwt","nodejs","postgresql","rest-api"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/YanchikFox.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-23T19:08:31.000Z","updated_at":"2025-10-03T16:48:42.000Z","dependencies_parsed_at":"2025-10-03T18:18:06.684Z","dependency_job_id":"e60d78db-138e-470f-94e4-9a4e2c059a90","html_url":"https://github.com/YanchikFox/ClothingShop-API","commit_stats":null,"previous_names":["yanchikfox/clothingshop-api"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/YanchikFox/ClothingShop-API","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YanchikFox%2FClothingShop-API","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YanchikFox%2FClothingShop-API/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YanchikFox%2FClothingShop-API/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YanchikFox%2FClothingShop-API/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/YanchikFox","download_url":"https://codeload.github.com/YanchikFox/ClothingShop-API/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YanchikFox%2FClothingShop-API/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278621843,"owners_count":26017253,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-06T02:00:05.630Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker-compose","express","jwt","nodejs","postgresql","rest-api"],"created_at":"2025-10-06T13:45:22.747Z","updated_at":"2025-12-30T21:16:58.046Z","avatar_url":"https://github.com/YanchikFox.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ClothingShop API  ![Node CI](https://github.com/YanchikFox/ClothingShop-API/actions/workflows/node-ci.yml/badge.svg)\n\n\nA Node.js + Express backend that powers the ClothingShop mobile application. It exposes REST endpoints for browsing products, managing user accounts, and keeping track of cart contents in a PostgreSQL database.\n\n## Features\n\n- Product catalogue with optional gender-based filtering and keyword search.\n- Email/password authentication with hashed credentials and JWT-based sessions.\n- Persistent shopping cart per user with quantity management.\n- Category listing for quick navigation in the client application.\n\n## Tech stack\n\n- [Node.js](https://nodejs.org/) with [Express](https://expressjs.com/)\n- [PostgreSQL](https://www.postgresql.org/) via the official `pg` driver\n- [bcryptjs](https://www.npmjs.com/package/bcryptjs) for password hashing\n- [jsonwebtoken](https://www.npmjs.com/package/jsonwebtoken) for issuing JWT access tokens\n\n## Prerequisites\n\n- Node.js 18+\n- npm 9+\n- Docker (optional, for running PostgreSQL locally via Docker Compose)\n\n## Getting started\n\n1. **Install dependencies**\n\n   ```bash\n   npm install\n   ```\n\n2. **Configure environment variables**\n\n   ```bash\n   cp .env.example .env\n   ```\n\n   Update `.env` with the connection details for your PostgreSQL instance and choose a strong `JWT_SECRET` for token signing.\n\n3. **Start PostgreSQL**\n\n   - Quick start (recommended):\n\n     ```bash\n     docker compose up -d\n     ```\n\n     This launches a local PostgreSQL 16 container with the credentials that match the defaults found in `.env.example` (`myuser` / `mypassword`, database `mydatabase`).\n\n   - Alternatively, point the app at any PostgreSQL instance and make sure the credentials in your `.env` file match the remote server.\n\n4. **Create the schema and seed data**\n\n   ```bash\n   node setup-database.js\n   ```\n\n   The script drops and recreates the tables (`users`, `categories`, `products`, `carts`, `cart_items`) and inserts a small set of demo products and categories for local testing.\n\n5. **Start the development server**\n\n   ```bash\n   node server.js\n   ```\n\n   By default the API listens on `http://localhost:3000` (configurable via the `PORT` environment variable).\n\n## Environment configuration\n\nConfiguration is now driven via environment variables (loaded from `.env` during local development). The API recognises the following keys:\n\n| Variable | Description | Default |\n| --- | --- | --- |\n| `PORT` | Port for the Express server. | `3000` |\n| `DATABASE_URL` | Full PostgreSQL connection string. If provided it takes precedence over the individual DB_* settings. | _none_ |\n| `DB_HOST` | Database host for local/dev use. | `localhost` |\n| `DB_PORT` | Database port. | `5432` |\n| `DB_USER` | Database user. | `myuser` |\n| `DB_PASSWORD` | Database password. | `mypassword` |\n| `DB_NAME` | Database name. | `mydatabase` |\n| `DB_SSL` | Set to `true` to enable SSL connections (uses `rejectUnauthorized: false`). | `false` |\n| `JWT_SECRET` | Secret used for signing and verifying JWTs. **Change this in production.** | `dev-secret-change-me` |\n\nProduction deployments should provide secure values for these variables via the hosting platform's secret management system instead of storing them in `.env`.\n\n## API reference\n\n| Method \u0026 Path | Description |\n| --- | --- |\n| `GET /api/products?gender=male\\|female\\|unisex` | List products, optionally filtered by gender. |\n| `GET /api/categories` | Fetch all product categories. |\n| `GET /api/search?q=\u003cterm\u003e` | Search products by name or description. |\n| `POST /api/register` | Create a new user account. Expects `{ \"email\": string, \"password\": string }`. |\n| `POST /api/login` | Authenticate a user. Returns `{ token }` on success. |\n| `GET /api/profile` | Get the authenticated user profile. Requires `x-auth-token` header. |\n| `GET /api/cart` | Retrieve the authenticated user's cart. Requires `x-auth-token`. |\n| `POST /api/cart` | Add/update an item in the cart. Body: `{ \"productId\": string, \"quantity\": number }`. Requires `x-auth-token`. |\n| `PUT /api/cart/item/:productId` | Set the quantity for a cart item. Body: `{ \"quantity\": number }`. Requires `x-auth-token`. |\n| `DELETE /api/cart/item/:productId` | Remove a product from the cart. Requires `x-auth-token`. |\n\n## Project scripts\n\n- `npm install` – install dependencies\n- `node setup-database.js` – initialise or reset the database\n- `node server.js` – start the API server\n- `npm test` – run the Jest test suite against the API endpoints\n\n## Useful tips\n\n- For local Android emulator testing, expose the API using the host machine's IP address or a tunnelling service such as ngrok.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyanchikfox%2Fclothingshop-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyanchikfox%2Fclothingshop-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyanchikfox%2Fclothingshop-api/lists"}