Coder Social home page Coder Social logo

trishantpahwa / expressjs-route-coverage Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kodekrewtechnologies/expressjs-route-coverage

0.0 1.0 0.0 52 KB

An express JS plugin to print registered routes of an expressJS app.

License: Apache License 2.0

JavaScript 100.00%

expressjs-route-coverage's Introduction

ExpressJS-Route-Coverage

An express JS plugin to print registered routes of an expressJS app.

This project is inspired by the following Stack Overflow Answer.

Only supports express: ^4.18.2.

Made with love in India && javascript

npm code-sandbox

Installation

CLI

# On your terminal, run the following command:
npm i -g expressjs-route-coverage

ExpressJS application development plugin

# On your terminal, run the following command:
npm i -D expressjs-route-coverage
# Add the following script to your `package.json` file:
"scripts": {
    "log-routes": "erc -p <path> -v <variable> -o <output> -f <output-file>"
}

A good way is to add it before the mocha command in your package.json file.

    "scripts": {
        "test": "erc -p <path> -v <variable> -o <output> -f <output-file> && mocha",
    }

ExpressJS application middleware plugin

# On your terminal, run the following command:
npm i expressjs-route-coverage

Usage

CLI

  _____   ____     ____ 
 | ____| |  _ \   / ___|
 |  _|   | |_) | | |    
 | |___  |  _ <  | |___ 
 |_____| |_| \_\  \____|
                        

Usage: erc -p <path>  -v <variable> -o <output> -f <output-file>
┌──────────────────────────────────────────────────────────────────────────┐
│                                                                          │
│                                                                          │
│   An express JS plugin to print registered routes of an expressJS app.   │
│                                                                          │
│                                                                          │
└──────────────────────────────────────────────────────────────────────────┘


Options:
      --version      Show version number                               [boolean]
  -p, --path         Path to ExpressJS App file
  -v, --variable     Variable name of ExpressJS App                     [string]
  -o, --output       Output type path                                   [string]
  -f, --output-file  Output file path
      --help         Show help                                         [boolean]

Example

erc -p ../my-express-api/app.js -v app -o json -f ../my-express-api/routes.json

# or

npm run log-routes -p ../my-express-api/app.js -v app -o json -f ../my-express-api/routes.json

ExpressJS application plugin

In your ExpressJS application, add the following code at the end of the file:
    const express = require('express');
    const { logRegisteredRoutes } = require('expressjs-route-coverage');
    .
    .

    const app = express();
    .
    .
    .
    console.log(logRegisteredRoutes(app));

Developed by Trishant Pahwa at KodeKrew Technologies.

expressjs-route-coverage's People

Contributors

trishantpahwa avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.