From c49cd95a9852ef7d106075a6508f5fce9341b3e7 Mon Sep 17 00:00:00 2001 From: Daniel Brahneborg Date: Wed, 21 Aug 2019 07:33:14 +0200 Subject: [PATCH] plugin2: counter --- index.js | 1 + plugin2/index.js | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 plugin2/index.js diff --git a/index.js b/index.js index 798530a..6afe7fa 100644 --- a/index.js +++ b/index.js @@ -7,6 +7,7 @@ app.use(express.json()); // connect the plugin(s) app.use('/plugin', require('./plugin')) +app.use('/plugin2', require('./plugin2')) // catch 404 and forward to error handler const createError = require('http-errors') diff --git a/plugin2/index.js b/plugin2/index.js new file mode 100644 index 0000000..ceef6ff --- /dev/null +++ b/plugin2/index.js @@ -0,0 +1,18 @@ + +const express = require('express') +const router = express.Router() + +var counter = 0; + +router.post('/before_receive', (req, res) => { + const qe = req.body.qe + counter = counter + 1 + res.send('qe.MESSAGE=Message ' + counter + ': ' + qe.MESSAGE) +}) + +router.use((req, res, next) => { + res.status(404).end() +}) + +module.exports = router +