Research
Recent Trends in Malicious Packages Targeting Discord
The Socket research team breaks down a sampling of malicious packages that download and execute files, among other suspicious behaviors, targeting the popular Discord platform.
typed-url-params
Advanced tools
Readme
Types your URL parameters in compliance with Express.js router and https://github.com/pillarjs/path-to-regexp
npm install typed-url-params
type Params = ParseUrlParams<"/test"> // { }
type Params = ParseUrlParams<"/:abc"> // { abc: string }
type Params = ParseUrlParams<"/:abc+"> // { abc: string | string[] }
type Params = ParseUrlParams<"/:abc*"> // { abc?: string | string[] }
type Params = ParseUrlParams<"/users/:userId"> // { userId: string }
type 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:
function handleGet<TypedUrl extends string>(
app: Express.Application,
url: TypedUrl,
handler: (req: Express.Request & { params: ParseUrlParams<TypedUrl> }, res: Express.Response, next) => void
) {
// noop
}
import { ParseUrlParams } from "typed-url-params"
function assert<T extends string = string>(r: ParseUrlParams<T>): asserts r is ParseUrlParams<T> {}
assert<"/:asd/b">({ asd: "" })
assert<"/xxx/:asd/bbb:dsa">({ asd: "", dsa: "" })
assert<"/xxx/:asd/bbb/:dsa">({ asd: "", dsa: "" })
assert<"/xxx/:asd/bbb/:dsa">({ asd: "", dsa: "" })
assert<"/:test*-bar">({ test: [] })
assert<"/:test*-bar">({})
assert<"/:test*-bar">({ test: "asd" })
assert<"/:test*-bar">({ test: ["asd"] })
assert<"/:test+-bar">({ test: [""] })
assert<"/:test*">({ test: [] })
assert<"/:test+">({ test: "" })
assert<"/:test+">({ test: [""] })
assert<"/:test?-bar">({ test: "" })
assert<"/:test?">({ test: "" })
assert<"/:test(\\d+)">({ test: "" })
assert<"/:test(\\d+)+">({ test: "" })
assert<"/:test(\\d+)+">({ test: [""] })
assert<"/route.:ext(json|xml)?">({})
assert<"/route.:ext(json|xml)?">({ ext: "" })
assert<"/route.:ext(json|xml)">({ ext: "" })
assert<"/route.:ext(json|xml)+">({ ext: "" })
assert<"/route.:ext(json|xml)+">({ ext: [""] })
assert<"/route.:ext([a-z]+)*/:asd">({ ext: [""], asd: "" })
assert<"/route.:ext([a-z]+)*/:asd">({ asd: "" })
assert<"/route.:ext([a-z]+)*">({ ext: [""] })
assert<"/route.:ext([a-z]+)/:asd">({ ext: "", asd: "" })
assert<"/:test(.*)">({ test: "" })
assert<"/route\\(\\\\(\\d+\\\\)\\)">({})
assert<"/{apple-}?icon-:res(\\d+).png">({ res: "" })
assert<"/:foo/:bar">({ foo: "", bar: "" })
assert<"/users/:user_id/:asd+">({ user_id: "", asd: [] })
assert<"/flights/:from-:to">({ from: "", to: "" })
FAQs
Types your URL parameters in compliance with Express.js router and https://github.com/pillarjs/path-to-regexp
We found that typed-url-params demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Research
The Socket research team breaks down a sampling of malicious packages that download and execute files, among other suspicious behaviors, targeting the popular Discord platform.
Security News
Socket CEO Feross Aboukhadijeh joins a16z partners to discuss how modern, sophisticated supply chain attacks require AI-driven defenses and explore the challenges and solutions in leveraging AI for threat detection early in the development life cycle.
Security News
NIST's new AI Risk Management Framework aims to enhance the security and reliability of generative AI systems and address the unique challenges of malicious AI exploits.