Gathering detailed insights and metrics for Router
Gathering detailed insights and metrics for Router
Gathering detailed insights and metrics for Router
Gathering detailed insights and metrics for Router
vue-router
> - This is the repository for Vue Router 4 (for Vue 3) > - For Vue Router 3 (for Vue 2) see [vuejs/vue-router](https://github.com/vuejs/vue-router).
@vue/cli-plugin-router
router plugin for vue-cli
react-router
Declarative routing for React
react-router-dom
Declarative routing for React web applications
npm install Router
Typescript
Module System
Node Version
NPM Version
72
Supply Chain
98.8
Quality
75.3
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Verify real, reachable, and deliverable emails with instant MX records, SMTP checks, and disposable email detection.
Total Downloads
59,352
Last Day
50
Last Week
268
Last Month
1,027
Last Year
12,882
MIT License
3 Stars
29 Commits
2 Forks
2 Watchers
2 Branches
1 Contributors
Updated on Feb 23, 2024
Minified
Minified + Gzipped
Latest Version
2.1.0
Package Id
Router@2.1.0
Size
6.13 kB
NPM Version
3.10.8
Node Version
6.9.1
Cumulative downloads
Total Downloads
Last Day
-38.3%
50
Compared to previous day
Last Week
-0.7%
268
Compared to previous week
Last Month
-6.3%
1,027
Compared to previous month
Last Year
-7.5%
12,882
Compared to previous year
1
A simple NodeJS server routing system.
This is a very simple routing system for your NodeJS RESTy apps, tested mainly with the http module.
Important Note: As of version 2, there's almost no backwards compatibility
with versions prior to it (Last was 1.3.0), so if you don't want to upgrade your
project, better force version 1.3.0! Also the functionality of .also
has been
dropped for now.
You can include a router instance globally like:
1global.Router = require('Router');
Then, you can define few routes in lately included files, or in the same file:
1//You could specify a raw regex, but you will have to specify the anchor characters!
2Router.when("/home", (req, res, m) => {
3 res.end("Hey! You're in '/home'!");
4})
5//You can specify the method to match, so if you specify this route but the method does not match, it will be ignored.
6.when("/putSomething/(.+)", ['PUT'], (req, res, m) => {
7 res.end(`Hehe, we're going to put ${m[1]}`);
8})
9//Final is now ".finally()" but .final is maintained as sugar syntax for finally.
10.finally((req, res) => {
11 res.writeHead(404, {'Content-Type': 'plain/text'});
12 res.end("Sorry, nothing found :(");
13});
If you want to pass a raw RegExp you can, like: Router.when(/^\/home$/, ...)
Note the ^
and $
, they are automatically added when you pass a string, but
in regex you have to define them explicitly.
Want to use classes? No problem, use hooks! Router.$()
1class Actrl {
2
3 static aRoute(req, m) {
4 return "Hehe, a route!";
5 }
6
7}
8Router.$("/home", Actrl.aRoute);
Easy huh? Remember that $
is a syntactic sugar for Router.hook
.
You can use non-static methods also:
1class A { 2 constructor(prop){ 3 this.prop = prop; 4 Router.$("/lol", this.lol); 5 } 6 lol(req, m){ 7 return `Here your controller instance holds ${this.prop} property!`; 8 } 9} 10let a = new A(); //...
If you return a string, the default header is sent
{'Content-Type': 'plain/text'}
and the code is 200
.
You can change this returning an object:
1{ 2 code: 200, 3 head: { 4 {'Content-Type': 'text/html'} 5 }, 6 data: `Hey! <b>Bold</b> stoopid html <i>haha</i>` 7}
All fields are optional. If you return an object with only data and this data is an object, the server will respond a 200 code with application/json content type and the object will be stringified:
1{data: { 2 "a": "json", 3 "is": [ 4 "cool", 5 "very cool" 6 ] 7}}
With the Es7
spec there will be included the function decorators that use a
similar syntax to java's annotations @someDec(asdasd)
but untill now you will have
to stick to Router.$
.
For more examples, see /examples folder.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/29 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
Project has not signed or included provenance with any releases.
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-03-03
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More