A MongoDB-backed @imqueue RPC microservice that owns customer accounts and their garage of cars for the Car-Wash tutorial.
It stores users (credentials, profile, admin/active flags) and the list of cars each user has
registered. It never speaks HTTP — every method is exposed as a typed remote call over the
@imqueue/rpc Redis message queue and is consumed by the gateways (api, api-rest), which in
turn serve the front-ends.
This repo is one piece of the imqueue-sandbox tutorial — a complete car-wash booking app built from independent RPC microservices that communicate over a Redis-backed message queue.
| Repo | Role | Store |
|---|---|---|
| user | Customer accounts & their garage | MongoDB |
| auth | Login, JWT issuing & revocation | Redis |
| car | Car catalog (makes / models / types) | in-memory |
| time-table | Washing reservations & schedule | PostgreSQL |
| api | GraphQL gateway orchestrating the fleet | — |
| api-rest | REST/OpenAPI gateway over the same fleet | — |
| web-app | React front-end on api (GraphQL/Relay) |
— |
| web-app-rest | React front-end on api-rest (REST) |
— |
The backend services are transport-agnostic: two interchangeable gateways and two independent front-ends prove the same fleet can be fronted by completely different API styles without changing a single service.
Exposed by the User service (src/User.ts) via @expose():
| Method | Signature | Description |
|---|---|---|
version |
() |
Running service name / version / repository. |
update |
(data, fields?) |
Upsert a user (create when no _id); bcrypt-hashes password. |
fetch |
(criteria, fields?) |
Find one user by email (contains @) or by id. |
find |
(filters?, fields?, skip?, limit?) |
Paginated, filtered user list (case-insensitive). |
count |
(filters?) |
Count users matching filters. |
carsCount |
(idOrEmail) |
Number of cars in a user's garage. |
addCar |
(userId, carId, regNumber, fields?) |
Add a car; enforces the per-user limit and unique reg-number. |
removeCar |
(carId, fields?) |
Remove a car by its garage sub-document id. |
getCar |
(userId, carId) |
Fetch a single car from a user's garage. |
The password is bcrypt-hashed on write and never returned to callers that don't request it.
A user's garage is capped at 6 cars, duplicate registration numbers are rejected, and the
email field is unique.
Environment variables (loaded from an optional .env via process.loadEnvFile()):
| Variable | Default | Purpose |
|---|---|---|
USER_DB |
mongodb://localhost/user |
MongoDB connection string. |
IMQ_REDIS |
localhost:6379 |
Redis endpoint(s) for the RPC message queue. |
BCRYPT_ROUNDS |
10 |
bcrypt cost factor for password hashing. |
Development mode (rebuilds and restarts on change):
npm run devProduction mode:
npm startBoth start the service under the imqueue label user. A MongoDB instance must be reachable at
USER_DB and Redis at IMQ_REDIS.