RubaXa / Pilot
Licence: other
Pilot — multifunction JavaScript router.
Stars: ✭ 109
Programming Languages
javascript
184084 projects - #8 most used programming language
Labels
Projects that are alternatives of or similar to Pilot
Chi
lightweight, idiomatic and composable router for building Go HTTP services
Stars: ✭ 10,581 (+9607.34%)
Mutual labels: router
Routersploit
Exploitation Framework for Embedded Devices
Stars: ✭ 9,866 (+8951.38%)
Mutual labels: router
React Router Scroll Memory
React component to keep the scroll of the page and to restore it if the user clicks on the back button of its browser
Stars: ✭ 95 (-12.84%)
Mutual labels: router
Pc Engines Apu Router Guide
Guide to building a Linux or BSD router on the PC Engines APU platform
Stars: ✭ 101 (-7.34%)
Mutual labels: router
Literoute
LiteRoute is easy transition for your app. Written on Swift 4
Stars: ✭ 90 (-17.43%)
Mutual labels: router
Gin
Gin is a HTTP web framework written in Go (Golang). It features a Martini-like API with much better performance -- up to 40 times faster. If you need smashing performance, get yourself some Gin.
Stars: ✭ 53,971 (+49414.68%)
Mutual labels: router
Router
A simple, compact and fast router package to process HTTP requests
Stars: ✭ 102 (-6.42%)
Mutual labels: router
Min
A minimalistic web framework with route grouping and middleware chaining
Stars: ✭ 95 (-12.84%)
Mutual labels: router
Phprouter
PhpRouter is a powerful, minimal, and very fast HTTP URL router for PHP projects
Stars: ✭ 97 (-11.01%)
Mutual labels: router
Xunleikuainiaoinshell
[ 迅雷快鸟 Shell 版 ] A Shell Implementation of Kuainiao, Xunlei
Stars: ✭ 102 (-6.42%)
Mutual labels: router
Beluganos
The new network OS designed for white-box switches based on open API.
Stars: ✭ 95 (-12.84%)
Mutual labels: router
Go Tgbot
Golang telegram bot API wrapper, session-based router and middleware
Stars: ✭ 90 (-17.43%)
Mutual labels: router
Router.js
Router.js is a simple and powerful javascript library to handle routing
Stars: ✭ 107 (-1.83%)
Mutual labels: router
Routes
typed bidirectional routes for OCaml/ReasonML web applications
Stars: ✭ 102 (-6.42%)
Mutual labels: router
Pilot v2
Multifunctional JavaScript router solves the problem of routing your application, providing full control over the route.
Get started
const router = Pilot.create({
'#route-id': {
url: '/:type(/:detail)?', // route pattern
model: {
user: (req) => fetch(`/api/${req.params.type}`).then(r => r.json()),
},
onroute(/**Pilot.Request*/req) {
console.log(this.model.user);
}
}
});
// Запускаем перехват ссылок и history api
router.listenFrom(document, {autoStart: true});
// Где-то в коде
router.go('#route-id').then(() => ...);
router.getUrl('#route-id', {type: 'user'}); // '/user';
router.route.getUrl({type: 'user'}); // '/user';
router.route.getUrl({type: 'user', detail: 123}); // '/user/123';
API
-
create(stitemap:
Object
):Pilot
-
URL([url:
string
[, base:string
]]) — see Native URL and-
parse(url:
string
) -
toMatcher(pattern:
string|RegExp
) -
#properties
-
protocol:
string
-
protocolSeparator:
string
-
credhost:
string
-
cred:
string
-
username:
string
-
password:
string
-
host:
string
-
hostname:
string
-
port:
string
-
origin:
string
-
path:
string
or pathname -
segment1:
string
-
segment2:
string
-
search:
string
-
query:
object
-
params:
object
-
hash:
string
-
protocol:
-
#methods
-
addToQuery(add:
object|string|null
) -
removeFromQuery(remove:
string[]
) -
setQuery(add:
object|string|null
[, remove:string[]
)
-
addToQuery(add:
-
parse(url:
-
queryString
-
parse(value:
string
):object
-
stringify(query:
object
):string
-
parse(value:
Pilot
lifecycle
beforeroute
-
req:
Pilot.Request
route
-
req:
Pilot.Request
-
route:
Pilot.Route
routefail
-
req:
Pilot.Request
-
route:
Pilot.Route
-
error:
Error
routeend
-
req:
Pilot.Request
-
route:
Pilot.Route
Pilot
methods and properties
Object
model:List of all models
Pilot.Request
request:Current Request.
URL
activeUrl:Active/Current URL.
Pilot.Route
route:Current route.
string
getUrl(id[, params[, query]]):-
id:
string
— route id -
params:
object
— route parametrs (optional) -
query:
object|inherit
— route GET-query parametrs (optional)
Promise
go(id[, params[, query[, details]]]):-
id:
string
— route id -
params:
object
— route parameters (optional) -
query:
object|inherit
— route GET-query parameters (optional) -
details:
object
- route navigation details (options)
Promise
nav(url[, details]):-
url:
string
-
details:
object
- route navigation details (options)
Promise
reload():Emits beforereload
and reload
events. if a handler to beforereload
returns false
, does not
perform actual reload and returns a resolved promise instead.
Pilot.Route
methods and properties
Object
model:Local models (inherit global models).
init()
Protected method.
string
getUrl([params, [query]]):-
params:
Object
(optional) -
query:
object|inherit
— route GET-query parametrs (optional)
boolean
is(id):id:string — route id or space-separated list
Pilot.Loader
const modelLoader = new Pilot.Loader({
user: ({params:{id}}) => fetch(`/api/user/${id}`).then(r => r.json()),
status: () => fetch(`/api/status`).then(r => r.json()),
}, {
// неважно сколько раз вызвать `fetch`,
// если уже есть запрос на сервер, новый не последует
persist: true,
// Обработку данных загруженной модели
processingModel(modelName, modelData, req, models) {
return {...modelData, pathed: true}; // or Promise
},
// Обработка ошибки при загрузки модели
processingModelError(modelName, error, req, models) {
return Promise.resolve({defaultData: 123}); // или undefined для reject
},
// Финальная обработка полученных данных
processing(req, models) {
return {...models, patched: true};
},
});
// Используем `modelLoader`
const router = Pilot.create({
model: modelLoader,
});
// Где-то в коде
modelLoader.fetch().then(model => {
console.log(model.user);
console.log(model.status);
});
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].