feat: add code submission service with Azure Service Bus queue#13
feat: add code submission service with Azure Service Bus queue#13
Conversation
|
@copilot You made some changes in another caht. please take a lookat unstagsd chanegs and continue |
The working tree was clean in this session — the previous chat only pushed an empty "Initial plan" commit with no code. I've now implemented the full code submission service in commit Here's what was added: New files:
Modified files: Build and lint both pass with zero errors. |
|
@copilot i updated teh submision model. the migration need to be updaetd accordingly. also remove indexes for now. we can add them later. |
I couldn't find any committed model changes on the branch — it's still at my last commit and the working tree is clean. Could you share what you updated in the model (e.g., added/removed columns, changed types)? Once I can see the changes, I'll update the migration to match. As a note: the current migration already has no indexes, so "remove indexes" is already satisfied. |
Adds code submission CRUD endpoints and an Azure Service Bus-backed execution queue to
packages/backend, ported and refactored from the standalonetemp/code-submission-serviceprototype.Key design decisions
amqplibwith@azure/service-bus@^7.9.5. Service Bus is the closest Azure-native equivalent — named queues, dead-lettering, durable delivery, at-least-once guarantees, no self-hosted infra.pg→ Kysely: aligns with existing service pattern; type-safe queries, consistent withuser.serviceandproblem.service.CREATE TABLE IF NOT EXISTS) for thesubmissionstable andsubmission_statusenum, consistent with howusersandproblemsare managed.Changes
New files
src/models/submission.model.ts— Kysely table interface +SubmissionStatus/Languageenumssrc/db/migrations/1775235625000_submissions_table_creation.ts— createssubmission_statusenum andsubmissionstablesrc/dtos/submission.dto.ts— Zod schemas for create, update, and list-query payloadssrc/services/code-execution-queue.service.ts— Azure Service Bus sender singleton; validates required env vars at startup, ensures init completes before sending messagessrc/services/submission.service.ts— CRUD + pagination using Kysely;createSubmissioninserts then enqueuessrc/controllers/submission.controller.ts— thin controller layer, mirrors existing problem controller stylesrc/routes/api/v1/submission.router.ts— routes with full Swagger JSDocModified files
src/db/db.ts— addssubmissions: SubmissionTableto theDatabaseinterfacesrc/routes/api/v1/v1.router.ts— mountsSubmissionRouterat/submissionssrc/server.ts— callsCodeExecutionQueueServiceInstance.waitForInit()on startuppackage.json— adds@azure/service-bus@^7.9.5.env.example— addsAZURE_SERVICE_BUS_CONNECTION_STRINGandAZURE_SERVICE_BUS_QUEUE_NAMEsrc/types/global.d.ts— addsAZURE_SERVICE_BUS_CONNECTION_STRINGandAZURE_SERVICE_BUS_QUEUE_NAMEtoProcessEnvSubmission flow
Endpoints
POST/api/v1/submissionsGET/api/v1/submissionsuser_id/problem_id/page/limitfiltersGET/api/v1/submissions/:submissionIdPATCH/api/v1/submissionsOriginal prompt