gp21-router
v1.0.1
Published
A lightweight router lib that implement with express route style
Downloads
5
Maintainers
Readme
gp21 Router
A lightweight router lib that implement with express route style
Languages
Documentation
Get Start
Installation
npm i --save gp21-router
Usage
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>gp21 Router</title>
</head>
<body>
<div id="app">
<div id="router-view"></div>
</div>
</body>
</html>
import gp21Router from 'gp21-router'
const router = new gp21Router('router-view')
// route config
router.route('/index', (req, res, next) => {
res.render(
`hallo world`
)
})
router.route('*', (req, res, next) => {
res.redirect('/index')
})
Note: if your are not using webpack, your can simply import it to your html file
<script type="text/javascript" src="https://unpkg.com/gp21-router"></script>
Please see the document for more details
Live demo
Running Example
1.clone the repo
npm i
npm run dev
open http://localhost:8080/
2.Test
npm run test // or => karma start
3.lint
npm run lint
Contributors
Thanks goes to these wonderful people (emoji key):
License
Copyright (c) 2017-present, hwen [email protected]