Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/paulooosrj/router-khan-js
Sistema de rotas com Ecmascript 6 ( Suporte a Modulos )
https://github.com/paulooosrj/router-khan-js
es6 es6-javascript es6-modules javascript router routers
Last synced: about 2 months ago
JSON representation
Sistema de rotas com Ecmascript 6 ( Suporte a Modulos )
- Host: GitHub
- URL: https://github.com/paulooosrj/router-khan-js
- Owner: paulooosrj
- License: mit
- Created: 2017-08-27T17:18:56.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T02:15:26.000Z (about 1 year ago)
- Last Synced: 2024-05-21T14:13:27.124Z (7 months ago)
- Topics: es6, es6-javascript, es6-modules, javascript, router, routers
- Language: HTML
- Homepage:
- Size: 472 KB
- Stars: 25
- Watchers: 3
- Forks: 2
- Open Issues: 71
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- divertidalista - RouterKhanJS - Router System
README
# Router Khan Version ( Ecmascript 6 )
### About Router Khan JS
- Fast and simple.
- Routes without needing the hash.
- History was used api.
### Documentation
- Complete system documentation is available online at [this link](https://paulaodev.github.io/RouterKhanJs/documentation).
### Contribution
- Send error reports, suggestions, and upload requests to the [GitHub issue tracker](https://github.com/PaulaoDev/router-khan-js/issues).
- Read the [File](https://github.com/PaulaoDev/router-khan-js/blob/master/CONTRIBUTING.md).
### System Requirements
- Ecmascript >= 6
### Init RouterKhanJS using Modules [``]
```javascript
"use strict";import RouterProvide from "./src/Router.js";
(async window => {
const Router = RouterProvide.create();// example simple route
Router.any("/", async (data, viewRouter) => {
console.log("Init !!");
viewRouter.innerHTML = "<h1>Router init</h1>";
});
// simple route using middleware
Router.any(
"/home",
async (data, viewRouter, next) => {
data.id = Math.random() * 1000;
next();
},
async ({ id }, viewRouter, next) => {
const homePromise = () =>
new Promise((resolve, reject) => {
resolve("Home !! id is: " + id);
});
viewRouter.innerHTML = await homePromise();
next();
},
() => console.log("Finish exec middleware")
);
// simple route redirect
Router.any("/toRedirect", () => {
Router.redirect("/redirected");
});
// simple route receive router
Router.any("/redirected", (data, viewRouter) => {
viewRouter.innerHTML = `<h1>Redirecionado com sucesso!!</h1>`;
});
// simple route with parameters
Router.any("/perfil/{name}/{id}", async ({ name, id }, viewRouter) => {
viewRouter.innerHTML = `<h1>Perfil ${name} is ID ${id}</h1>`;
});
// init router
Router.dispatch();
```
### License
The RouterKhan is licensed under the MIT license. See [License File](https://github.com/PaulaoDev/router-khan-js/blob/master/LICENSE) for more information.
### Contact
- [Facebook](https://fb.com/PauloRodriguesYT).
- [Whatsapp](https://bit.ly/whatsappdopaulo).