Socket
Socket
Sign inDemoInstall

connect-router-decorators

Package Overview
Dependencies
73
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    connect-router-decorators

TODO


Version published
Maintainers
1
Created

Readme

Source

connect-router-decorators

A bundle of decorators of express.Router. TS/babel supported.

Quick start

import express from 'express';
import path from 'path';
import { Router } from 'connect-router-decorators';

const app = express();
const router = new Router(app, path.resolve('./controllers'), {
  searchPattern: '**/*.{js,ts}', // default
});

const bootstrap = async () => {
  router.beforeAll((req, res, next) => {
    if (!req.startTime) {
      req.startTime = Date.now();
    }

    next();
  });

  router.afterAll((req, res, next) => {
    if (req.startTime) {
      const last = Date.now() - req.startTime;

      console.log(`Request ${req.method.toUpperCase()} - ${req.path} take ${last}ms.`);
    }

    next();
  });

  app.use(router.routes());

  app.listen(3000, () => {
    console.log(`app running on http://localhost:3000`);
  });
};

bootstrap();

TODO(s)

  • Multi-roots router support.

License

See LICENSE

Keywords

FAQs

Last updated on 20 Dec 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc