Socket
Book a DemoInstallSign in
Socket

route-path-getter

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

route-path-getter

Class to orginize the router paths of the application.

2.0.0
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

route-path-getter

Class to orginize the router paths of an application. Could be used with any Framework like Angular, React, Vue, Ionic, Express or any javascript based app.

Install

npm i route-path-getter

or

yarn add route-path-getter

Example Use

import { RoutePathGetter } from "route-path-getter";

//Creating Instance
export const appRoutes = new RoutePathGetter({
  home: {
    value: "/",
  },
  profile: {
    value: "/profile/:id",
    params: {
      id: "",
    },
  },
});

//Using Instance with Type Safety
appRoutes.path("home"); // returns '/'
appRoutes.path("profile"); // returns '/profile/:id

appRoutes.path("profile", { params: { id: "1" } }); // returns '/profile/1

// appRoutes.path("profile", { params: { ss: "" } }); // TypeError: Object literal may only specify known properties, and 'ss' does not exist in type '{ id: string; }'.ts(2345);

// appRoutes.path('other'); // Argument of type '"other"' is not assignable to parameter of type 'RouteKeys'.

// USING QUERIES
appRoutes.path("profile", { params: { id: "1" }, query: "id=123" }); // returns '/profile/1?id=123

Keywords

router

FAQs

Package last updated on 14 Nov 2020

Did you know?

Socket

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.