From fec2381144e7e72e07a79341fb96591d1cf48766 Mon Sep 17 00:00:00 2001 From: Daniel Brahneborg Date: Mon, 12 Aug 2019 12:11:44 +0200 Subject: [PATCH] /before_receive and /route --- plugin/index.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/plugin/index.js b/plugin/index.js index a14f339..63297ac 100644 --- a/plugin/index.js +++ b/plugin/index.js @@ -2,12 +2,23 @@ const express = require('express') const router = express.Router() -router.get('/', (req, res) => { - res.send('ok') +router.post('/before_receive', (req, res) => { + console.log('in before_receive, body:', req.body) + res.send(Buffer.from('qe.MESSAGE = new message')) }) -router.post('/before_receive', (req, res) => { - res.send('ok') +router.post('/route', (req, res) => { + console.log('in route, qe:', req.body.qe) + const qe = req.body.qe + let respbuf = '' + if (qe.DESTADDR === '123') + respbuf = Buffer.from('ROUTE = out') + res.send(respbuf) +}) + +router.use((req, res, next) => { + console.log('nothing to do for %s %s', req.method, req.url) + res.status(404).end() }) module.exports = router