6.0.3 • Published 6 months ago

@types/express-list-endpoints v6.0.3

Weekly downloads
3,292
License
MIT
Repository
github
Last release
6 months ago

Installation

npm install --save @types/express-list-endpoints

Summary

This package contains type definitions for express-list-endpoints (https://github.com/AlbertoFdzM/express-list-endpoints).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/express-list-endpoints.

index.d.ts

// Type definitions for express-list-endpoints 6.0
// Project: https://github.com/AlbertoFdzM/express-list-endpoints
// Definitions by: S Joseph <https://github.com/sjoseph7>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

/* =================== USAGE ===================
import * as express from "express";
import listEndpoints from "express-list-endpoints";

const app = express();

app.route('/')
  .all(function namedMiddleware(req, res) {
    // Handle request
  })
  .get(function(req, res) {
    // Handle request
  })
  .post(function(req, res) {
    // Handle request
  });

app.route('/about')
  .get(function(req, res) {
    // Handle request
  });

console.log(listEndpoints(app));

// It omits the 'all' verbs.
[{
    path: '/',
    methods: ['GET', 'POST'],
    middlewares: ['namedMiddleware', 'anonymous', 'anonymous']
  },
  {
    path: '/about',
    methods: ['GET'],
    middlewares: ['anonymous']
}]

 =============================================== */

import express = require('express');

declare function listEndpoints(app: express.Express): listEndpoints.Endpoint[];

declare namespace listEndpoints {
    interface Endpoint {
        path: string;
        methods: string[];
        middlewares: string[];
    }
}

export = listEndpoints;

Additional Details

  • Last updated: Wed, 18 Aug 2021 01:01:23 GMT
  • Dependencies: @types/express
  • Global values: none

Credits

These definitions were written by S Joseph.