vanilla_router

npm install vanilla_router

Usage no npm install needed!

<script type="module">
  import vanillaRouter from 'https://cdn.skypack.dev/vanilla_router';
</script>

README

vanilla_router documentation

To Install:

npm install vanilla_router

To Require:

var router = require('vanilla_router');

To Use:

  1. Create routes file in routes folder (ex. routes/samplesRoutes.js)
    router.get('/samples', (req, res) => {
      console.log('samples GET route hit');
      res.end();
    });
    
    router.post('/samples', (req, res) => {
      console.log('samples POST route hit');
      res.end();
    });
    
    router.put('/samples', (req, res) => {
      console.log('samples PUT route hit');
      res.end();
    });
    
    router.delete('/samples', (req, res) => {
      console.log('samples DELETE route hit');
      res.end();
    });
    
  2. Add routes to server in server.js
    var students = require(__dirname + '/routes/studentsRoutes.js');
    var samples = require(__dirname + '/routes/samplesRoutes.js');
    
    students(newRouter);
    samples(newRouter);
    
  3. Add test for routes in test folder (ex. test/samplesRoutes-test.js) *optional