Skip to content

BeeNext/BeeNext-Backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BeeNext Backend

REST API backend for BeeNext, a campus marketplace where BINUS students can register, list items, browse listings, manage their own products, and receive marketplace notifications.

Built with Express.js, TypeScript, Prisma, PostgreSQL, and S3-compatible object storage.


Tech Stack

  • Runtime: Node.js + TypeScript
  • Framework: Express.js v5
  • Database: PostgreSQL
  • ORM: Prisma
  • Auth: JWT + bcryptjs
  • Uploads: Multer + AWS SDK S3 client
  • Storage: S3-compatible bucket, such as Cloudflare R2 or Tigris
  • Docs: Swagger UI at /api/docs

Getting Started

Prerequisites

  • Node.js 20 or newer
  • PostgreSQL database
  • S3-compatible bucket credentials

Installation

npm install

Environment Variables

Create a .env file from the example file:

copy .env.example .env

Fill in the values:

DATABASE_URL=postgresql://user:password@localhost:5432/beenext
PORT=3000
JWT_SECRET=your_jwt_secret

S3_ENDPOINT_URL=your_s3_endpoint_url
S3_REGION=auto
S3_BUCKET_NAME=your_bucket_name
S3_ACCESS_KEY_ID=your_access_key_id
S3_SECRET_ACCESS_KEY=your_secret_access_key

Database Setup

npm run db:migrate
npm run db:seed

Running

# Development
npm run dev

# Production
npm run build
npm start

API Endpoints

Base API path: /api

Method Endpoint Auth Description
GET / - Health check
GET /api/docs - Swagger API documentation
GET /assets/:fileName - Serve uploaded or seeded asset
GET /api/auth - Get all users
POST /api/auth/register - Register student account
POST /api/auth/login - Login with NIM and password
GET /api/auth/me JWT Get current user
POST /api/auth/change-password JWT Change current user's password
POST /api/auth/change-phone-number JWT Change current user's phone number
POST /api/auth/logout - Logout session
GET /api/products - List products with pagination, search, and category filter
GET /api/products/me JWT List current user's products
GET /api/products/:id - Get product detail
POST /api/products JWT Create product with up to 5 images
PATCH /api/products/:id JWT Update owned product
DELETE /api/products/:id JWT Delete owned product
GET /api/categories - List product categories
GET /api/regions - List BINUS campus regions
GET /api/notifications JWT Get current user's notifications

Scripts

Command Description
npm run dev Start development server with hot reload
npm run build Compile TypeScript and resolve path aliases
npm start Run compiled production build
npm run db:migrate Run Prisma migrations
npm run db:seed Seed database data

Project Structure

BE_BeeNext/
|-- prisma/
|   |-- schema.prisma        # Database schema
|   |-- seed.ts              # Seed data
|   `-- migrations/          # Prisma migration history
|-- src/
|   |-- config/              # Environment, Prisma, CORS, Swagger config
|   |-- middlewares/         # Express middleware, such as JWT auth
|   |-- modules/             # Domain modules
|   |   |-- assets/          # Asset serving
|   |   |-- auth/            # Register, login, profile, account updates
|   |   |-- categories/      # Product categories
|   |   |-- notifications/   # User notifications
|   |   |-- products/        # Marketplace product CRUD
|   |   `-- regions/         # Campus regions
|   |-- types/               # Shared TypeScript types
|   |-- utils/               # Response, storage, parsing, auth helpers
|   `-- index.ts             # Express app entry point
|-- package.json
`-- tsconfig.json

Notes

  • Product create and update requests use multipart/form-data.
  • Product images are uploaded to the configured bucket and returned as public API asset URLs.
  • Protected endpoints expect an Authorization: Bearer <token> header.

About

BeeNext Backend 🌸

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors