Gathering detailed insights and metrics for typed-url-params
Gathering detailed insights and metrics for typed-url-params
npm install typed-url-params
Typescript
Module System
Node Version
NPM Version
79
Supply Chain
92.4
Quality
75.2
Maintenance
100
Vulnerability
100
License
TypeScript (93.25%)
Makefile (6.75%)
Total Downloads
271,723
Last Day
40
Last Week
511
Last Month
5,475
Last Year
108,456
86 Stars
3 Commits
3 Watching
3 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
1.0.1
Package Id
typed-url-params@1.0.1
Size
5.23 kB
NPM Version
6.14.11
Node Version
14.16.0
Publised On
08 Apr 2021
Cumulative downloads
Total Downloads
Last day
-64.6%
40
Compared to previous day
Last week
-50.2%
511
Compared to previous week
Last month
-79.3%
5,475
Compared to previous month
Last year
-2.6%
108,456
Compared to previous year
4
Types your URL parameters in compliance with Express.js router and https://github.com/pillarjs/path-to-regexp
npm install typed-url-params
1type Params = ParseUrlParams<"/test"> // { } 2type Params = ParseUrlParams<"/:abc"> // { abc: string } 3type Params = ParseUrlParams<"/:abc+"> // { abc: string | string[] } 4type Params = ParseUrlParams<"/:abc*"> // { abc?: string | string[] } 5type Params = ParseUrlParams<"/users/:userId"> // { userId: string } 6type Params = ParseUrlParams<"/flights/:from-:to"> // { from: string, to: string }
This library only offers typings. You must write your own wrapper for Express. You can do it like this:
1function handleGet<TypedUrl extends string>( 2 app: Express.Application, 3 url: TypedUrl, 4 handler: (req: Express.Request & { params: ParseUrlParams<TypedUrl> }, res: Express.Response, next) => void 5) { 6 // noop 7}
1 2import { ParseUrlParams } from "typed-url-params" 3 4function assert<T extends string = string>(r: ParseUrlParams<T>): asserts r is ParseUrlParams<T> {} 5 6assert<"/:asd/b">({ asd: "" }) 7assert<"/xxx/:asd/bbb:dsa">({ asd: "", dsa: "" }) 8assert<"/xxx/:asd/bbb/:dsa">({ asd: "", dsa: "" }) 9assert<"/xxx/:asd/bbb/:dsa">({ asd: "", dsa: "" }) 10assert<"/:test*-bar">({ test: [] }) 11assert<"/:test*-bar">({}) 12assert<"/:test*-bar">({ test: "asd" }) 13assert<"/:test*-bar">({ test: ["asd"] }) 14assert<"/:test+-bar">({ test: [""] }) 15assert<"/:test*">({ test: [] }) 16assert<"/:test+">({ test: "" }) 17assert<"/:test+">({ test: [""] }) 18assert<"/:test?-bar">({ test: "" }) 19assert<"/:test?">({ test: "" }) 20assert<"/:test(\\d+)">({ test: "" }) 21assert<"/:test(\\d+)+">({ test: "" }) 22assert<"/:test(\\d+)+">({ test: [""] }) 23assert<"/route.:ext(json|xml)?">({}) 24assert<"/route.:ext(json|xml)?">({ ext: "" }) 25assert<"/route.:ext(json|xml)">({ ext: "" }) 26assert<"/route.:ext(json|xml)+">({ ext: "" }) 27assert<"/route.:ext(json|xml)+">({ ext: [""] }) 28assert<"/route.:ext([a-z]+)*/:asd">({ ext: [""], asd: "" }) 29assert<"/route.:ext([a-z]+)*/:asd">({ asd: "" }) 30assert<"/route.:ext([a-z]+)*">({ ext: [""] }) 31assert<"/route.:ext([a-z]+)/:asd">({ ext: "", asd: "" }) 32assert<"/:test(.*)">({ test: "" }) 33assert<"/route\\(\\\\(\\d+\\\\)\\)">({}) 34assert<"/{apple-}?icon-:res(\\d+).png">({ res: "" }) 35assert<"/:foo/:bar">({ foo: "", bar: "" }) 36assert<"/users/:user_id/:asd+">({ user_id: "", asd: [] }) 37assert<"/flights/:from-:to">({ from: "", to: "" })
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
7 existing vulnerabilities detected
Details
Reason
Found 0/3 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
detected GitHub workflow tokens with excessive permissions
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
license file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
security policy file not detected
Details
Score
Last Scanned on 2024-07-08
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