diff --git a/index.js b/index.js index 0638434..3cf2102 100644 --- a/index.js +++ b/index.js @@ -67,6 +67,19 @@ app.post('/:cid/:hook_id/:hook_token', (req, res) => { res.status(200).json({ status: 'ok' }); }); +app.get('/:cid', (req, res) => { + const cid = req.params.cid; + if (!cid) { + console.log(`Invalid request: cid is required`.red); + return res.status(400).json({ error: 'cid is required' }); + } + if (!cidsInUse.has(cid)) { + console.log(`No client connected with cid: ${cid}`.red); + return res.status(504).json({ error: 'no client connected' }); + } + res.status(200).json({ status: 'ok', message: 'Client is connected and ready to receive your webhooks!' }); +}); + const PORT = process.env.SERVER_PORT || 3000; app.listen(PORT, () => { console.log(`Server is listening on port ${PORT}`.green);