Skip to content

Latest commit

 

History

History
70 lines (41 loc) · 1.23 KB

readme.md

File metadata and controls

70 lines (41 loc) · 1.23 KB

routeplus

NPM version

Express Route++

Installation

$ yarn add routeplus

Named Routes

Name your routes and reference to them anywhere within your app.

Route plus provides a plug in-out interface.

// using named routes

const express = require('express')
const rp = require('routeplus')

let app = express()

// Create a new router
let router = rp.router(express.Router(), {
  prefix: '/user'
})

// Define Routes as usual + fluent api
router.match(['GET'], '/settings', handler).as('setting')

router.get('/dasboard', handler).as('dashboard')

router.get('/p/:username', handler).as('profile')

app.use('/user', router.mount())

Generate urls from route names anywhere in app

rp.url('dashboard') // outputs "/user/dashboard"

rp.url('profile', {username: 'johndoe'}); // outputs  /user/p/morrelinko

API

routeplus.router()

routeplus.url()

routeplus.routeTable()

routeplus.clear()

Testing

Clone the repository from github and run the commands below

$ yarn install 
$ yarn test

Contribution

View list of all contributors Here