defang
defang copied to clipboard
Defang generate should include a healthcheck endpoint
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.