Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@penname/routepath
Advanced tools
npm install --save @penname/routepath
Convenient API route interface.
const RoutePath = require('@penname/routepath')
const route = RoutePath.instance({ path: '/article/:id', baseUrl: 'example.com' })
const url = route.buildUrl({
params: { id: 'abc123' },
query: { position: 'middle', ref: 'twitter' },
})
console.log(url)
// prints: example.com/article/abc123?position=middle&ref=twitter
const path = route.buildPath({
params: { id: 'abc123' },
query: { position: 'middle', ref: 'twitter' },
})
console.log(path)
// prints: /article/abc123?position=middle&ref=twitter
#instance()
Create a route path instance with a minimum of baseUrl
, path
:
const route = RoutePath.instance({ path: '/article/:id', baseUrl: 'https://example.com' })
#buildUrl()
Builds the url from the route path with the provided params
and query
const route = RoutePath.instance({ path: '/article/:id', baseUrl: 'localhost:3000/api/' })
const url = route.buildUrl({
params: { id: 'abc123' },
query: { position: 'middle', ref: 'twitter' },
})
console.log(url)
// prints: localhost:3000/api/article/abc123?position=middle&ref=twitter
#buildPath()
Builds the url path, no host, from the route path with the provided params
and query
const route = RoutePath.instance({
path: '/user/:userId/article/:articleId',
baseUrl: 'http://www.example.com',
})
const path = route.buildPath({
params: { userId: 'u1cba', articleId: 'abc123' },
query: { position: 'middle', date: 1609036608349 },
})
console.log(path)
// prints: /user/u1cba/article/abc123?position=middle&date=1609036608349
#fromSerialized()
const routeFromJsonString = RoutePath.fromSerialized(
`{path: "/user/:id/articles", "baseUrl": 'example.com/api/' }`,
)
const url = route.buildUrl({
params: { id: 'u1cba' },
query: { from: 'abc456', limit: 15 },
})
console.log(url)
// prints: example.com/api/user/u1cba/articles?from=abc456&limit=15
FAQs
Convenient API route interface.
The npm package @penname/routepath receives a total of 115 weekly downloads. As such, @penname/routepath popularity was classified as not popular.
We found that @penname/routepath demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.