swarfless

2.0.0 • Public • Published

swarfless

A nano router for Zeit's micro

const micro = require('micro');
const Swarfless = require('swarfless');
const r = new Swarfless();


r.get('/', async () => 'Root of server');

// or
const { get, post } = r;

get('/hello/:name', async (req) => `Hi, ${req.params.name}`);
post('/set-name/:name', async (req) => `Setting name to ${req.params.name}`);

module.exports = r.get_route_handler();

Changes

Version 2 has changes to avoid storing the route in the module itself, which interferes with hot-reloading from micro-dev. Due to those changes, you must now create a Swarfless instance before using the route-building methods.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.0.0
    2
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 2.0.0
    2
  • 1.0.1
    1
  • 1.0.0
    1

Package Sidebar

Install

npm i swarfless

Weekly Downloads

4

Version

2.0.0

License

Unlicense

Last publish

Collaborators

  • randallsquared