coap-polka

1.0.0 • Public • Published

CoapPolka

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]

Todo

  • proxying CoAP request to HTTP
  • response JSON format writer

Install

$ npm install --save coap-polka

Usage

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`);
  });

API

TBA

License

Copyright (c) 2018 Ahmad Anshorimuslim Licensed under the MIT license.

/coap-polka/

    Package Sidebar

    Install

    npm i coap-polka

    Weekly Downloads

    1

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    17.9 kB

    Total Files

    13

    Last publish

    Collaborators

    • ans4175