defang icon indicating copy to clipboard operation
defang copied to clipboard

Defang generate should include a healthcheck endpoint

Open raphaeltm opened this issue 7 months ago • 1 comments

defang generate gave me a really nice little app that includes this:

const app = express();
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({ extended: true }));

  app.post('/task', async (req, res) => {
    const { name, data } = req.body;
    const job = await taskQueue.add(name, data);
    res.send({ jobId: job.id });
  });

  app.get('/task/:id', async (req, res) => {
    const job = await taskQueue.getJob(req.params.id);
    if (job) {
      res.send({ id: job.id, data: job.data, status: await job.getState() });
    } else {
      res.status(404).send({ error: 'Job not found' });
    }
  });

  app.listen(3000, () => {
    console.log('Server started on port 3000');
  });

Unfortunately, that app will fail the default healthcheck.

raphaeltm avatar Jul 17 '24 21:07 raphaeltm