Socket
Socket
Sign inDemoInstall

2way-router

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

2way-router - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

1

lib/Route.js

@@ -90,2 +90,3 @@ var RegExpParam = require('./param/RegExpParam');

var usedParams = {};
params = params || {};

@@ -92,0 +93,0 @@ function createUrl() {

2

package.json
{
"name": "2way-router",
"version": "1.1.0",
"version": "1.1.1",
"description": "2-way router",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -83,3 +83,3 @@ 2way-router

function pageController(req, res, params) {
var pageContent = 'page: ' + name + ', params: <pre>' + JSON.stringify(params, null, ' ') + '</pre>';
var pageContent = 'page: ' + name + ', params: <pre>' + JSON.stringify(params.merge(), null, ' ') + '</pre>';
vow.all(links.map(function (link) {

@@ -109,3 +109,3 @@ return router.url(link.page, link.params || {});

app.use(function (req, res) {
router.findRoute(req.path).then(function (info) {
router.findRoute(req.url).then(function (info) {
info.route.controller()(req, res, info.params);

@@ -118,1 +118,31 @@ }, function () {

```
#### API
##### Router
```router.route(pathTemplate)``` - creates new ```Route```
```router.findRoute(url, [options])``` - searchs for matching route, returns ```Promise<Route>```
```router.url(routeName, [params])``` - creates url for route with name *routeName*, returns ```Promise<string>```
```router.registerType(typeConstructor, names)``` - registers new param type for further usage in routes, must be called before any ```router.route``` calls, type example can be found at [NumberParam.js]
[NumberParam.js]: lib/param/NumberParam.js
##### Route
```route.name([newName])``` - get/set route name
```route.controller([newController])``` - get/set route controller
```route.url([params])``` - creates url for this route, returns ```Promise<string>```
##### RouteParams
```params.getRouteParam(name, [defaultValue=null])``` - get route param value (for example ```id``` in route ```"/news/{id:int}/"```)
```params.getQueryParam(name, [defaultValue=null])``` - get query string param with given *name* (last one if many are present), returns ```string```
```params.getQueryParamValues(name)``` - get all values for query string param with given *name*, returns ```string[]```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc