New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-create-url

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-create-url

nvm use 14.20.0 npm uninstall --save-dev node-sass yarn add node-sass node-sass": "^4.14.0",

latest
Source
npmnpm
Version
0.1.6
Version published
Maintainers
1
Created
Source

In this small library, you can use typescript object/methods for building route/api urls.

1.First step - create interface with all routings in your web app.

interface IAppRoute {
  auth: {
    account: {
      id: (id?: string) => IUrlItem;
    };
    login: IUrlItem;
  };
}

2.Seccond step - create object and call createUrls() method with similar implementation

const appRoutes = createUrls<IAppRoute>({
  auth: {
    login: EMPTY_URL_ITEM,
    account: {
      id: (id?: string) => EMPTY_URL_ITEM,
    },
  },
});

3. Example of usage.

axios.get(appRoutes.auth.account.id("e87a8340-1a81-4013-a8c8-c5ab8ec205ea")) // instead axios.get("/auth/check/e87a8340-1a81-4013-a8c8-c5ab8ec205ea")
...
describe("create-urls", () => {
  it("test urls", () => {
    expect(appRoutes.auth).toEqual("/auth");
    expect(appRoutes.auth.login).toEqual("/auth/login");
    expect(appRoutes.auth.account.id()).toEqual("/auth/check/:id");
    expect(appRoutes.auth.account.id("e87a8340-1a81-4013-a8c8-c5ab8ec205ea").toEqual("/auth/check/e87a8340-1a81-4013-a8c8-c5ab8ec205ea");
  });
});

FAQs

Package last updated on 21 Sep 2023

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