Socket
Socket
Sign inDemoInstall

@chialab/router

Package Overview
Dependencies
1
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @chialab/router

A simple agnostic router for Web Apps.


Version published
Weekly downloads
11
decreased by-84.72%
Maintainers
1
Install size
521 kB
Created
Weekly downloads
 

Readme

Source

Router • A simple agnostic Router for Web Apps.

Documentation link Source link Authors link NPM License


Install

$ npm install @chialab/router
# or
$ yarn add @chialab/router

Use via cdn:

<script type="text/javascript" src="https://unpkg.com/@chialab/router-js"></script>

Example

import Router from '@chialab/router';

const appRouter = new Router();
appRouter.on('/user/:username', function(id) {
    fetchUserById(id);
});
appRouter.on('/posts/:id', function(id) {
    fetchPostById(id);
});
appRouter.on('/posts', function() {
    listPosts();
});
appRouter.on('*', function() {
    page404();
});
appRouter.start();

Development

Build status codecov

Requirements

In order to build and test Router, the following requirements are needed:

  • NodeJS (>= 10.0.0)
  • Yarn
  • RNA (>= 3.0.0)

Build the project

Install the dependencies and run the build script:

$ yarn install
$ yarn build

This will generate the UMD and ESM bundles in the dist folder, as well as the declaration file.

Test the project

Run the test script:

$ yarn test

License

Router is released under the MIT license.

Keywords

FAQs

Last updated on 12 Apr 2022

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