template-router

    1.0.3 • Public • Published

    template-router

    Known Vulnerabilities Build Status codecov Maintainability

    Define routes for express, koa-router or similar using tagged template literals.

    Example

    const express = require('express');
    const routes = require('template-router');
     
    const app = express();
     
    routes(app)`
      GET /hello/:name ${
        function sayHello(req, res) {
          const name = req.params.name;
          res.send(`Hello, ${name}`);
        }
      }
     
      POST ${/some regex/} ${
        function doPostThing(req, res) {
          // ...
        }
      }
    `;
     
    app.listen(8080);

    Install

    npm i template-router

    DownloadsWeekly Downloads

    1

    Version

    1.0.3

    License

    MIT

    Unpacked Size

    13.8 kB

    Total Files

    12

    Last publish

    Collaborators

    • p7g