1
0
Fork 0
mirror of https://github.com/sbrl/powahroot.git synced 2024-11-21 22:22:59 +00:00
Find a file
2019-04-27 00:38:02 +01:00
Client Start writing the documentation, but there's a bunch of work left still to do. 2019-04-27 00:38:02 +01:00
Server Start writing the documentation, but there's a bunch of work left still to do. 2019-04-27 00:38:02 +01:00
Shared Start writing the documentation, but there's a bunch of work left still to do. 2019-04-27 00:38:02 +01:00
.gitignore Import from Nibriboard-Panel 2019-04-26 23:35:10 +01:00
.tern-project Import from Nibriboard-Panel 2019-04-26 23:35:10 +01:00
index.mjs Add logo & licence 2019-04-26 23:56:29 +01:00
LICENSE Initial commit 2019-04-26 23:52:55 +01:00
logo-large.png Start writing the documentation, but there's a bunch of work left still to do. 2019-04-27 00:38:02 +01:00
logo.piskel Add logo & licence 2019-04-26 23:56:29 +01:00
logo.png Add logo & licence 2019-04-26 23:56:29 +01:00
package-lock.json Start writing the documentation, but there's a bunch of work left still to do. 2019-04-27 00:38:02 +01:00
package.json Start writing the documentation, but there's a bunch of work left still to do. 2019-04-27 00:38:02 +01:00
README.md Start writing the documentation, but there's a bunch of work left still to do. 2019-04-27 00:38:02 +01:00

powahroot

Client and server-side routing micro frameworks

Powerahroot is a pair of micro routing frameworks, presented as an ES6 module:

  • The first is for client-side single-page web applications
  • The other is for handling server-side Node.js requests

Getting Started

Install powahroot as a dependency with npm:

npm install --save powahroot

Then import the router you're after:

import { ServerRouter } from 'powahroot';
import { ClientRouter } from 'powahroot';

Usage

Paths

Powahroot supports multiple syntax bells and whistles when defining routes. These are documented below:

Syntax Meaning
/index.html Regular route. Matches exactly what it says on the tin.
* Special key(word?) that matches any route. Must be present on its own without any other characters.
/add/vegetable/:name/:weight Parameters. Match values an pull them into an object automatically. Does not like forward slashes in parameter values.
/images/::path Parameter values with forward slashes. If you want to use parameters, but need values to be able to contain forward slashes /, this is for you. Don't forget you can mix-and-match this with the previous example!

Client

Initialise a new router like this:

const router = new ClientRouter({
	// Options object. Default settings:
	verbose: false, // Whether to be verbose in console.log() messages
	listen_pushstate: true, // Whether to react to browser pushstate events (excluding those generated by powahroot itself, because that would cause an infinite loop :P)
});

Licence

Everything in this repository except the logo is licenced under the _Mozilla Public License 2.0.

The logo itself is © Copyright Starbeamrainbowlabs 2019. All rights reserved - though you may use it when linking to this project (or to advertise usage in a 'powered by' logo).