Add some static files
This commit is contained in:
parent
ecd29073e9
commit
59f220eea9
34
index.js
34
index.js
|
@ -6,7 +6,7 @@ const colors = require("colors");
|
||||||
const app = express();
|
const app = express();
|
||||||
app.use(express.urlencoded({ extended: true }));
|
app.use(express.urlencoded({ extended: true }));
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
|
app.use(express.static('static'));
|
||||||
expressWs(app);
|
expressWs(app);
|
||||||
|
|
||||||
const hookEvent = new EventEmitter();
|
const hookEvent = new EventEmitter();
|
||||||
|
@ -67,8 +67,11 @@ app.post('/:cid/:hook_id/:hook_token', (req, res) => {
|
||||||
res.status(200).json({ status: 'ok' });
|
res.status(200).json({ status: 'ok' });
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/:cid', (req, res) => {
|
app.get('/:cid/:hook_id/:hook_token', (req, res) => {
|
||||||
const cid = req.params.cid;
|
const cid = req.params.cid;
|
||||||
|
const hookId = req.params.hook_id;
|
||||||
|
const hookToken = req.params.hook_token;
|
||||||
|
|
||||||
if (!cid) {
|
if (!cid) {
|
||||||
console.log(`Invalid request: cid is required`.red);
|
console.log(`Invalid request: cid is required`.red);
|
||||||
return res.status(400).json({ error: 'cid is required' });
|
return res.status(400).json({ error: 'cid is required' });
|
||||||
|
@ -77,7 +80,32 @@ app.get('/:cid', (req, res) => {
|
||||||
console.log(`No client connected with cid: ${cid}`.red);
|
console.log(`No client connected with cid: ${cid}`.red);
|
||||||
return res.status(504).json({ error: 'no client connected' });
|
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!' });
|
|
||||||
|
res.status(200).json({
|
||||||
|
status: 'ok',
|
||||||
|
message: 'Client is connected and ready to receive your webhooks!',
|
||||||
|
hook_id: hookId,
|
||||||
|
hook_token: hookToken
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
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!',
|
||||||
|
cid: cid
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const PORT = process.env.SERVER_PORT || 3000;
|
const PORT = process.env.SERVER_PORT || 3000;
|
||||||
|
|
BIN
static/favicon.ico
Normal file
BIN
static/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 162 KiB |
2
static/robots.txt
Normal file
2
static/robots.txt
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
User-agent: *
|
||||||
|
Disallow: /
|
Loading…
Reference in a new issue