rob-router

1.0.5 • Public • Published

rob-router

Overview

For non-SPA client side routers for WEB applications.

Description

Define the routes file, The controller matching the URL is executed.

Usage

Install

npm install rob-router

Demo

# routes
import RobRouter from 'rob-router';
import users from './users_controller';

const router = new RobRouter({
  controllers: {
    users
  },
  routes: {
    '/': 'users#root',
    'users(/)': 'users#index',
    'users/:userId': 'users#show',
    'users/:userId/posts(/)': 'users#posts',
    'users/:userId/posts/:postId(/)': 'users#postShow'
  }
});

router.run(location.href);
# user_controller
export default {
  root: () => {},
  index: () => {},
  show: userId => {},
  posts: userId => {},
  postShow: (userId, postId) => {}
};

Licence

MIT

Author

orangemittoo

Package Sidebar

Install

npm i rob-router

Weekly Downloads

0

Version

1.0.5

License

MIT

Unpacked Size

11.3 kB

Total Files

5

Last publish

Collaborators

  • orangemittoo