Add comprehensive documentation for employee learning platform
- Created handover document outlining design decisions and application functionality. - Developed implementation plan detailing phased approach for service development. - Specified ingestion service responsibilities, API surface, and processing pipeline.
This commit is contained in:
29
app/services/ingestion/src/routes/documents.ts
Normal file
29
app/services/ingestion/src/routes/documents.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import type { FastifyPluginAsync } from 'fastify';
|
||||
import { IngestBodySchema } from '../types.js';
|
||||
import { createJob, getJob } from '../jobs/queue.js';
|
||||
|
||||
const documentRoutes: FastifyPluginAsync = async (app) => {
|
||||
app.post('/ingest', async (request, reply) => {
|
||||
const parsed = IngestBodySchema.safeParse(request.body);
|
||||
if (!parsed.success) {
|
||||
return reply.status(400).send({ error: 'Invalid request body', details: parsed.error.format() });
|
||||
}
|
||||
const job = createJob(parsed.data);
|
||||
return reply.status(202).send({ jobId: job.id, status: job.status });
|
||||
});
|
||||
|
||||
app.get<{ Params: { jobId: string } }>('/status/:jobId', async (request, reply) => {
|
||||
const job = getJob(request.params.jobId);
|
||||
if (!job) {
|
||||
return reply.status(404).send({ error: 'Job not found' });
|
||||
}
|
||||
return reply.send({
|
||||
jobId: job.id,
|
||||
status: job.status,
|
||||
progress: job.progress,
|
||||
error: job.error,
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export default documentRoutes;
|
||||
Reference in New Issue
Block a user