CoapPolka is a minimal CoAP routing framework based on Polka. CoapPolka has basic support for routing, middleware, and sub-applications.
We offer features likewise in mandatory bullet-point format:
- Using node-coap as CoAP server
- Nearly identical application API & route pattern definitions with Express.js & Polka
- proxying CoAP request to HTTP [WIP]
- proxying CoAP request to HTTP
- response JSON format writer
$ npm install --save coap-polka
const coapPolka = require('coap-polka');
function hello(req, res, next) {
req.hello = 'world';
next();
}
function foo(req, res, next) {
req.foo = 'bar';
next();
}
coapPolka()
.use(hello, foo)
.get('/users/:id', (req, res) => {
console.log(`~> Hello, ${req.hello}`);
res.end(`User: ${req.params.id}`);
})
.listen(3000).then(_ => {
console.log(`> CoAP Running on localhost:3000`);
});
TBA
Copyright (c) 2018 Ahmad Anshorimuslim Licensed under the MIT license.