import { Router } from 'express';
import { getJob, listJobs } from '../jobs.js';

export const jobsRouter = Router();

jobsRouter.get('/', (_req, res) => {
  res.json(listJobs());
});

jobsRouter.get('/:jobId', (req, res) => {
  const job = getJob(req.params.jobId);
  if (!job) {
    res.status(404).json({ error: 'Job not found.' });
    return;
  }
  res.json(job);
});
