Skip to main content
Home

A simple package for performing client-side and server-side routing in your web applications. Designed by The Pheasant Framework.

This package works with Node.js, Deno, BrowsersIt is unknown whether this package works with Cloudflare Workers, Bun
It is unknown whether this package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
It is unknown whether this package works with Bun
This package works with Browsers
JSR Score
100%
Published
2 years ago (0.1.1)

Pheasant Routing Package

Custom badge Custom badge Custom Badge

This is the TypeScript Library used in making the base router class to be implemented by the Dart pheasant_router package in The Pheasant Framework.

Installation

This package is for utilization in the Pheasant Framework.

All you will need from this package to use the utilities in it is the bundled JavaScript files found in the dist/ folder.

Implement

JavaScript/Typescript

If you want to make use of this package on your own, you can make use of the functionality of this package from Deno.

import { Router } from 'https://deno.land/x/phs_routing/mod.ts';

let router = new Router();
router.get('/:id', (req) => {
    console.log(`${req.params.id}`);
});

// Initialise the router on the web application
router.init();

Dart

The pheasant_routing package (not yet) on [pub.dev] should contain full implementation of the library for the needs of the Pheasant Framework.

If you would want to make use of the router yourself (for contributions or whatever you would want to do), add the minified JavaScript file as a script tag, and then make use of the functionality in Dart as you normally would.

@JS('Router')
@staticInterop
class Router {
    external factory Router();
}

@staticInterop
extension on Router {
    //... other functions implemented
}

If you're not conversant with JS interop in Dart, it would be helpful to check this page on dart.dev.

Contributions and Extensions

The library, as of its current version, doesn't make use of any external libraries. This means that you can make use of, edit and implement this library in NodeJS and Deno (although the library was originally made in Deno).

If you want a full NPM implementation of this library, you can run the following command in the project root directory with the latest version of Deno:

deno run -A scripts/npm.ts

This will create an npm package using dnt in the npm directory.

To bundle/build this library, and generate the bundled, as well as minified, library, run the following command in the project root directory with the latest version of Deno:

deno run -A scripts/minify.ts

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@pheasant/router

Import symbol

import * as router from "@pheasant/router";
or

Import directly with a jsr specifier

import * as router from "jsr:@pheasant/router";

Add Package

pnpm i jsr:@pheasant/router
or (using pnpm 10.8 or older)
pnpm dlx jsr add @pheasant/router

Import symbol

import * as router from "@pheasant/router";

Add Package

yarn add jsr:@pheasant/router
or (using Yarn 4.8 or older)
yarn dlx jsr add @pheasant/router

Import symbol

import * as router from "@pheasant/router";

Add Package

vlt install jsr:@pheasant/router

Import symbol

import * as router from "@pheasant/router";

Add Package

npx jsr add @pheasant/router

Import symbol

import * as router from "@pheasant/router";

Add Package

bunx jsr add @pheasant/router

Import symbol

import * as router from "@pheasant/router";