express-route-detector

2.0.0 • Public • Published

Express-Router

a npm module for Express app inspired by Nuxt.js

Ability

  • Cli
  • Error handler
  • Auto fetch

Install

npm install express-route-detector

Usage

server.js

const { autoFetch, errorHandler } = require('express-route-detector')
const express = require("express");

const app = express();

app.use(autoFetch(express))
// By defualt pAddress = "hasPermission", cAddress = "controllerw", mAddress = "middleware" 

app.use(autoFetch(
  express,
  pAddress = "hasPermission", //Permission middleware name
  cAddress = "admins", //Controller folder
  mAddress = "middleware" //Middlewawre folder
  ))

app.use(errorHandler);

app.listen(port, () => {
  console.log(`Server runing on port: ${port}`);
});

controller.js

const home = (async (req, res) => {
    res.status(200).json({msg:'Hello world'});
})
module.exports = {
    baseRoute: "/",
    items: [
        {
            off: false,
            route: "/",
            method: "get",
            middleware: [], //option
            permission: "CONTENTUS", //option
            use: home
        },
    ]
}

Cli commends

  • routes
  • monit
  • init
  • env

Readme

Keywords

Package Sidebar

Install

npm i express-route-detector

Weekly Downloads

1

Version

2.0.0

License

ISC

Unpacked Size

21.8 kB

Total Files

9

Last publish

Collaborators

  • mrswift