1.2.1 • Published 4 years ago

route-blocker v1.2.1

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

route-blocker · GitHub license npm version Test and Build Status Issues Downloads

A middleware for expressjs to block or unblock a route

Install

Using npm

npm install route-blocker

Using yarn

yarn add route-blocker

Usage

In server.ts (or the file where app and routes are defined)

import { routeBlocker } from "route-blocker";

const BASE_ROUTE = "api/some-base-route";
export const subRouteToBlock = "some-sub-route";
const myRoute = `${BASE_ROUTE}/${subRouteToBlock}`;

app.use(myRoute, routeBlocker.middleware(subRouteToBlock));
app.get(myRoute, myRouteFunction);

In the file where the route blocking should be enabled/disabled

import { routeBlocker } from "route-blocker";
import { subRouteToBlock } from "src/server.ts";

routeBlocker.disableRoute(subRouteToBlock); // disable route

// do something

routeBlocker.enableRoute(subRouteToBlock); // enable route

To remove all route blockings

routeBlocker.clearBlockings();

Note

See the source for more details

License

route-blocker is MIT licensed.

1.2.1

4 years ago

1.2.0

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.1.0

6 years ago