This repo contains my final project for Back End Development with JavaScript at Winc Academy.
I built the API myself (routes, Prisma services, auth, validation, error handling). I used ChatGPT as a study helper to understand errors, debug failing tests, and improve things step by step. Final choices and changes were made by me, and verified by running the provided Postman and Newman tests locally.
A simple booking platform API with:
- Users
- Hosts
- Properties
- Bookings
- Reviews
- Amenities
Protected routes require:
Authorization: Bearer <token>
-
200 OK
Successful GET, PUT, DELETE (where applicable) -
201 Created
Successful POST -
400 Bad Request
Validation errors or invalid input -
401 Unauthorized
Missing or invalid token on protected routes -
404 Not Found
- Unknown route
- Resource by ID does not exist
- Filtered list endpoint returns nothing (example:
/users?username=Notfound)
-
409 Conflict
Creating a User or Host that already exists (duplicate username or email)
-
src/index.jsExpress entry point, routers, 404, global error handlerroutes/Route definitions per resourceservices/Prisma queries and business logic per resourcemiddleware/JWT auth middleware and global error handlerutils/prisma.jsShared Prisma clientdata/Seed JSON used byprisma/seed.js
-
prisma/schema.prismaPrisma schema (SQLite)seed.jsSeeds the database fromsrc/data
-
postman/collections/Newman test collections (positive + negative)environments/Postman environments
Full file map:
docs/file-map.txt
- Node.js 18+
- npm
From the project root:
npm installCreate a .env file in the project root:
DATABASE_URL="file:./prisma/dev.db"
AUTH_SECRET_KEY="dev-secret"
SENTRY_DSN=""
NODE_ENV=development
SENTRY_ENVIRONMENT=developmentNotes:
SENTRY_DSNcan be empty for local development.- SQLite DB file is
prisma/dev.db.
First time:
npx prisma db push
npx prisma db seedFull reset (recommended before running tests):
npx prisma db push --force-reset
npx prisma db seednpm run devServer runs at:
http://localhost:3000
Collections:
postman/collections/Bookings API.jsonpostman/collections/Bookings API Negative.json
Environment:
postman/environments/Local.postman_environment.json
Make sure:
baseURLislocalhost- Do not include
http:// - Do not include the port (the collection already adds
:3000)
Terminal 1 (keep running):
npm run devTerminal 2:
npm testExpected:
- Positive: 0 failed
- Negative: 0 failed
Full sample output:
docs/test-output.txt
Some tests create and delete data. If you rerun tests and things look weird, reset and reseed first:
npx prisma db push --force-reset
npx prisma db seed