WorthIt Backend API
Overview
- Node.js + Express 5 + TypeScript API for brands, reviews, and users.
- Uses MongoDB via Mongoose, JWT auth, Helmet for security, Winston logging.
Tech Stack
- Express, TypeScript, Mongoose, JWT, Helmet, Winston, express-validator.
Project Structure
- See
src/forconfig,controllers,db,middlewares,models,routes,services,utils,validators, plusindex.tsandserver.ts.
Setup
- Prereqs: Node 18+, MongoDB running locally or remote.
- Install:
npm install- Environment: create
.envinworthit-backend/with:
PORT=5000
DB_URL=mongodb://localhost:27017
CLIENT_URL=http://localhost:3000
JWT_SECRET_KEY=your-secret
NODE_ENV=development- Run (dev):
npm run dev- Build + start (prod):
npm run build
npm start- Seed sample data (optional):
npm run seedAPI
-
Base URL:
http://localhost:5000/api -
Auth (
/api/auth)- POST
/login→ Login and receive JWT - GET
/me→ Current user (requiresAuthorization: Bearer <token>)
- POST
-
Users (
/api/user)- POST
/→ Create user - GET
/→ List users - GET
/by-name→ List users (by name) - GET
/:userId→ Get user by ID - PATCH
/→ Update authenticated user (auth) - DELETE
/→ Delete authenticated user (auth)
- POST
-
Brands (
/api/brand)- POST
/→ Create brand (auth) - GET
/→ List brands - GET
/user/my-brands→ List brands created by current user (auth) - GET
/search/:identifier→ Get brand by name or slug - GET
/slug/:slug→ Get brand by slug - GET
/:brandId→ Get brand by ID - PATCH
/:brandId→ Update brand (auth) - DELETE
/:brandId→ Delete brand (auth) - POST
/:brandId/view→ Increment brand view count - PATCH
/:brandId/team→ Update brand team (auth)
- POST
-
Reviews (
/api/review)- POST
/brand/:brandId→ Create review for a brand (auth) - GET
/brand/:brandId→ List all reviews for a brand - GET
/user/:userId→ List reviews by user - GET
/:reviewId→ Get review by ID - PATCH
/:reviewId→ Update review (auth) - DELETE
/:reviewId→ Delete review (auth) - POST
/:reviewId/helpful→ Mark helpful (auth) - DELETE
/:reviewId/helpful→ Unmark helpful (auth)
- POST
-
Health (
/api/health)- GET
/→ Service status
- GET
Auth
- Send JWT in the
Authorizationheader:Bearer <token>. - Secret is configured via
JWT_SECRET_KEYin.env.
Scripts
dev: start with hot reload viatsxbuild: compile TypeScriptstart: run compiled serverseed: seed the database
Notes
- CORS is configured in
src/config/cors.tsusingCLIENT_URL. - Server boots from
src/index.tsand listens onPORT.
[Add your license here]
Built with ❤️ by the WorthIt team
For questions or issues:
- Create an issue on GitHub
- Email: [your-email@example.com]
Remember: This platform is built on honesty, not hype. Every line of code should serve that mission. 🎯