backend-final-project
Shipped: A service with a job running behind it
Repository: https://sgm322.github.io/finalBackendDevConnect/ Built for the Verified Backend Internship · Final project
Shipped: A service with a job running behind it
Project Overview I built an asynchronous Background Job Processing Service using Node.js, Express, MySQL (TiDB Cloud Serverless with TLS/SSL), and deployed it to Render. The architecture consists of: 1. REST API Server: Accepts job requests, validates authentication, enforces user scoping, and guarantees idempotency. 2. Background Worker: Polls pending tasks from the database, executes the job asynchronously, tracks attempt limits, and updates the status upon completion. 3. Persistent Database: Managed TiDB Cloud database storing jobs, idempotency keys, execution statuses, and timestamps. --- How to Test and Verify Acceptance Criteria Base URL: https://final-project-5nyu.onrender.com Auth Token: supersecrettoken123 1. Submit a New Job (POST /jobs) Run the following curl command to submit a background job: bash curl -X POST https://final-project-5nyu.onrender.com/jobs \ -H "Content-Type: application/json" \ -H "Authorization: Bearer supersecrettoken123" \ -H "x-user-id: user 101" \ -d '{"idempotencyKey": "demo-key-001"}' Expected Output: Returns HTTP 202 with jobId and status: "pending". 2. Check Job Status (GET /jobs/:id) Allow 1-2 seconds for the worker to process the job, then retrieve the status: Bash curl -X GET https://final-project-5nyu.onrender.com/jobs/1 \ -H "Authorization: Bearer supersecrettoken123" \ -H "x-user-id: user 101" Expected Output: Returns HTTP 200 with status: "completed" and execution details (processedAt). 3. Test Idempotency (Duplicate Prevention) Re-run the exact same POST request with the same idempotencyKey: Bash curl -X POST https://final-project-5nyu.onrender.com/jobs \ -H "Content-Type: application/json" \ -H "Authorization: Bearer supersecrettoken123" \ -H "x-user-id: user 101" \ -d '{"idempotencyKey": "demo-key-001"}' Expected Output: Returns HTTP 200 with the existing jobId and message "Job already registered" without creating a duplicate record. 4. Test Authentication & User Isolation Missing/invalid Authorization header returns HTTP 401 Unauthorized. Missing x-user-id header returns HTTP 401 Missing user identity. Repository: https://github.com/roh155/final project Live: https://final-project-5nyu.onrender.com Built for the Verified Backend Internship · Final project
Shipped: A service somebody else could run
A reading-list API with JWT-based accounts. Unauthenticated requests to /books return 401. Every book query is scoped to the caller's user id, and GET/DELETE on another user's book returns the same 404 as a nonexistent id -- so ownership can't be probed for. This is proven with node test-isolation.js, which registers two users, has user A create a book, and shows user B getting 404 on it while user A still gets 200. POST /books accepts an optional Idempotency-Key header: retrying the same key returns the original book instead of creating a second row -- node test-idempotency.js demonstrates this with real output (same id returned twice, list shows exactly one row). All 400 errors name the specific field that was wrong. No secret is committed -- JWT SECRET is read from an environment variable, with only a .env.example checked in. Reviewer steps: npm install, cp .env.example .env (set JWT SECRET), npm start, then run the two test scripts above in another terminal. Repository: https://github.com/GhulamMustafaAnsari/reading-list-service Live: https://reading-list-service.bonto.run/health Built for the Verified Backend Internship · Final project