Goal
- Maintain/extend the consumer-user API as features landed
- Core surface: create users, edit settings, promotions, search, account teardown
- Auth-scoped reads/writes via
firebaseId
Drop unDraw SVG in public/.../unDraw/
Backend developer on a student food-ordering startup. I owned consumer-user REST routes in Node.js / Express against a shared Mongoose User model—create, read, update, and delete keyed by Firebase UID—plus contracts, tests, and release with the team. (Restaurant accounts were managed separately.)
The mobile app needed predictable auth and profile APIs on MongoDB after Firebase signup. With frequent student turnover, the users backend also needed clear structure and shared rules so feature work (settings, promotions, search) could continue without breaking existing clients.
Goal
firebaseIdDrop unDraw SVG in public/.../unDraw/
Here are five example routes I wrote for the consumer-user API from routes/users.js against the shared User model (app users, not restaurant accounts). Each card describes the method and its path, what it does, the MongoDB operation, and the skills that were required to implement it.
POST /api/users/newUserAfter Firebase signup, look up the user by firebaseId. If missing, build a new User (anonymous or named), optionally generate a unique username, then persist.
MongoDB: findOne → new Model → save(). Idempotent first write into the User collection.
GET /api/users/Load the authenticated caller's document via firebaseId from req.user.uid, validate, return JSON (success + user).
MongoDB: auth-scoped User.findOne + shared validateUser guard—“get my profile.”
POST /api/users/editSettingsJoi-validate an updates object (email, username, names, receipts, privacy). Load the user, enforce username uniqueness, apply fields, save.
MongoDB: findOne (user) + findOne (username clash) → mutate fields → save().
DELETE /api/users/Find by firebaseId, delete the Firebase Auth user, then remove the MongoDB document—dual cleanup for account teardown.
MongoDB: findOne → document remove(), coordinated with the auth-provider delete.
GET /api/users/search:queryList active users with a field projection, filter named profiles, fuzzy-match name / username, then annotate friend and invite state from the caller's document.
MongoDB: find + selectprojection, then enrich from another doc's arrays (friendships / invites).