Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

find-my-way

Package Overview
Dependencies
Maintainers
2
Versions
112
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

find-my-way - npm Package Compare versions

Comparing version 1.4.1 to 1.5.0

2

example.js

@@ -17,3 +17,3 @@ 'use strict'

if (err) throw err
console.log('Server listening on: http://localost:3000')
console.log('Server listening on: http://localhost:3000')
})

@@ -38,2 +38,9 @@ 'use strict'

Router.prototype.on = function (method, path, handler, store) {
if (Array.isArray(method)) {
for (var k = 0; k < method.length; k++) {
this.on(method[k], path, handler, store)
}
return
}
assert.equal(typeof method, 'string', 'Method should be a string')

@@ -309,2 +316,6 @@ assert.equal(typeof path, 'string', 'Path should be a string')

Router.prototype.all = function (path, handler, store) {
this.on(httpMethods, path, handler, store)
}
module.exports = Router

@@ -311,0 +322,0 @@

{
"name": "find-my-way",
"version": "1.4.1",
"version": "1.5.0",
"description": "Crazy fast http radix based router",

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

"request": "^2.81.0",
"standard": "^10.0.2",
"tap": "^10.3.2"
"standard": "^10.0.3",
"tap": "^10.7.2"
}
}

@@ -80,2 +80,9 @@ # find-my-way

You can also pass an array of methods if you need to declare multiple routes with the same handler but different method.
```js
router.on(['GET', 'POST'], '/', (req, res, params) => {
// your code
})
```
<a name="shorthand-methods"></a>

@@ -96,2 +103,7 @@ ##### Shorthand methods

If you need a route that supports *all* methods you can use the `all` api.
```js
router.all(path, handler [, store])
```
<a name="lookup"></a>

@@ -98,0 +110,0 @@ #### lookup(request, response)

@@ -19,2 +19,14 @@ 'use strict'

test('Method should be a string (array)', t => {
t.plan(1)
const findMyWay = FindMyWay()
try {
findMyWay.on(['GET', 0], '/test', () => {})
t.fail('method shoukd be a string')
} catch (e) {
t.is(e.message, 'Method should be a string')
}
})
test('Path should be a string', t => {

@@ -56,2 +68,14 @@ t.plan(1)

test('Method is not an http method. (array)', t => {
t.plan(1)
const findMyWay = FindMyWay()
try {
findMyWay.on(['POST', 'GETT'], '/test', () => {})
t.fail('method is not a valid http method')
} catch (e) {
t.is(e.message, 'Method \'GETT\' is not an http method.')
}
})
test('The default route must be a function', t => {

@@ -58,0 +82,0 @@ t.plan(1)

@@ -28,2 +28,14 @@ 'use strict'

test('register a route with multiple methods', t => {
t.plan(2)
const findMyWay = FindMyWay()
findMyWay.on(['GET', 'POST'], '/test', () => {
t.ok('inside the handler')
})
findMyWay.lookup({ method: 'GET', url: '/test' }, null)
findMyWay.lookup({ method: 'POST', url: '/test' }, null)
})
test('default route', t => {

@@ -30,0 +42,0 @@ t.plan(1)

@@ -105,1 +105,20 @@ 'use strict'

})
test('should support `.connect` shorthand', t => {
t.plan(9)
const findMyWay = FindMyWay()
findMyWay.all('/test', () => {
t.ok('inside the handler')
})
findMyWay.lookup({ method: 'GET', url: '/test' }, null)
findMyWay.lookup({ method: 'DELETE', url: '/test' }, null)
findMyWay.lookup({ method: 'HEAD', url: '/test' }, null)
findMyWay.lookup({ method: 'PATCH', url: '/test' }, null)
findMyWay.lookup({ method: 'POST', url: '/test' }, null)
findMyWay.lookup({ method: 'PUT', url: '/test' }, null)
findMyWay.lookup({ method: 'OPTIONS', url: '/test' }, null)
findMyWay.lookup({ method: 'TRACE', url: '/test' }, null)
findMyWay.lookup({ method: 'CONNECT', url: '/test' }, null)
})
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