Gathering detailed insights and metrics for barista
Gathering detailed insights and metrics for barista
Gathering detailed insights and metrics for barista
Gathering detailed insights and metrics for barista
npm install barista
Typescript
Module System
Min. Node Version
NPM Version
74.9
Supply Chain
98.1
Quality
75.7
Maintenance
100
Vulnerability
100
License
JavaScript (56.36%)
CoffeeScript (43.35%)
Makefile (0.29%)
Total Downloads
186,452
Last Day
14
Last Week
66
Last Month
245
Last Year
2,778
110 Stars
102 Commits
22 Forks
9 Watching
2 Branches
8 Contributors
Minified
Minified + Gzipped
Latest Version
0.5.3
Package Id
barista@0.5.3
Size
373.57 kB
NPM Version
1.4.28
Cumulative downloads
Total Downloads
Last day
-12.5%
14
Compared to previous day
Last week
17.9%
66
Compared to previous week
Last month
-54.6%
245
Compared to previous month
Last year
41.6%
2,778
Compared to previous year
2
2
Barista is a simple URL router for NodeJS.
1router.get( '/:beverage/near/:location(.:format)' ) 2 .to( 'beverage.byLocation' ) 3 4router.first( '/coffee/near/90210', 'GET' ) 5// -> { controller:'beverage', action:'byLocation', beverage:'coffee', location:90210 } 6 7router.url({ 8 controller: 'beverage', 9 action: 'byLocation', 10 beverage: 'coffee', 11 location: 90210, 12 format: 'json' 13}) 14// -> '/coffee/near/90210.json'
Install via npm, thusly:
1npm install barista
1var Router = require('barista').Router; 2 3var router = new Router;
1router.match( '/products', 'GET' ) 2 .to( 'products.index' )
1router.match( '/products/:id', 'GET' ) 2 .to( 'products.show' ) 3 4router.match( '/profiles/:username', 'GET' ) 5 .to( 'users.show' ) 6 7router.match( '/products/:id(.:format)', 'GET' ) 8 .to( 'products.show' )
1router.get('/timezones/*tzname') 2 .to( 'timezones.select' ) 3 4router.first( '/timezones/America/Toronto', 'GET' ) 5// -> { controller:'timezones', action:'select', tzname:'America/Toronto' } 6 7 8router.match( '/*path(.:format)' ) // a "catch-all" route: 9 .to( 'errors.notFound' ) 10 11router.first( '/somewhere/that/four-oh-fours.json', 'GET' ) 12// -> { controller:'errors', action:'notFound', path:'somewhere/that/four-oh-fours', format:'json' }
1router.match( '/:beverage/near/:zipcode', 'GET' ) 2 .to( 'beverage.byZipCode' ) 3 .where({ 4 // an array of options 5 beverage: [ 'coffee', 'tea', 'beer', 'warm_sake' ], 6 // a regex pattern 7 zipcode: /^\d{5}(-\d{4})?$/ 8 }) 9 10router.match( '/:beverage/near/:location', 'GET' ) 11 .to( 'beverage.byLocation' ) 12 .where({ 13 // could be a postal code 14 // OR a zip code 15 // OR the word 'me' (geolocation FTW) 16 location: [ /^\d{5}(-\d{4})?$/, /^[ABCEGHJKLMNPRSTVXY]{1}\d{1}[A-Z]{1} *\d{1}[A-Z]{1}\d{1}$/, 'me' ] 17 })
1router.get( '/products/:id(.:format)' ) 2 .to( 'products.show' ) 3 4router.put( '/products/:id(.:format)' ) 5 .to( 'products.update' ) 6 7router.post( '/products' ) 8 .to( 'products.create' ) 9 10router.del( '/products' ) 11 .to( 'products.destroy' ) 12 13router.options( '/products' ) 14 .to( 'products.options' )
1router.resource( 'products' )
is equivalent to:
1router.get( '/products(.:format)' ) 2 .to( 'products.index' ) 3 4router.get( '/products/add(.:format)' ) 5 .to( 'products.add' ) 6 7router.get( '/products/:id(.:format)' ) 8 .to('products.show' ) 9 10router.get('/products/:id/edit(.:format)' ) 11 .to( 'products.edit' ) 12 13router.post('/products(.:format)' ) 14 .to( 'products.create' ) 15 16router.put('/products/:id(.:format)' ) 17 .to( 'products.update' ) 18 19router.del('/products/:id(.:format)' ) 20 .to( 'products.destroy' )
In some cases, you will need to remove routes on a running router. The router.remove( name )
method will work for this, but requires
use of the otherwise unused route.name( name )
method.
1router.match( '/products/:id', 'GET' ) 2 .to( 'products.show' ) 3 .name('products_show')
1 2router.remove('products_show') 3
The router.first( url, method [, callback] )
method can be used in two ways:
1var params = router.first( '/products/15', 'GET' )
OR
1router.first( '/products/15', 'GET', function( err, params ){ 2 if (err) { 3 // couldn't find match 4 } 5 // dispatch the request or something 6})
You can get all the matching routes like so:
1var params = router.all( '/products/15', 'GET' ) 2 3//=> [params, params, params....]
Pass in a params hash, get back a tasty string:
1router.url( { 2 controller: 'products', 3 action: 'show', 4 id: 5 5} ) 6//=> '/products/5' 7 8router.url( { 9 controller: 'products', 10 action: 'show', 11 id: 5, 12 format: 'json' 13} ) 14//=> '/products/5.json'
Set the optional second parameter to true
if you want
extra params appended as a query string:
1router.url({ 2 controller: 'products', 3 action: 'show', 4 id: 5, 5 format: 'json', 6 love: 'cheese' 7}, true ) 8//=> '/products/5.json?love=cheese'
...might be in the /docs
folder...
...or might not exist at all.
Shit happens.
Write a test that fails and add it to the tests folder, then create an issue!
Patches welcome :-)
I'm Kieran Huggins in Toronto, Canada.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 1/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
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
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-12-23
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