Socket
Book a DemoInstallSign in
Socket

@gpa/extract-params-from-path

Package Overview
Dependencies
Maintainers
0
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gpa/extract-params-from-path

Extract path parameters from an express path specification using only the Typescript type system, to provide statically typed request parameters

1.0.1
latest
Source
npmnpm
Version published
Maintainers
0
Created
Source

@gpa/extract-params-from-path

Gitlab Pipeline Status GitLab Issues GitLab License Node Current NPM Unpacked Size

Extract the parameters declared in an express path specification using the Typescript type system. Used to compute the list of available path parameters in a router in @gpa/type-safe-express.

The runtime path parameter parser of express is implemented in path-to-regexp, this library is compatible with:

@gpa/extract-params-from-path versionexpress versionpath-to-regexp version
0.x4.0-5.0.0-alpha.80.x
1.x5.0.0-beta.1-5.0.0-beta.33.2.0 (through router@2.0.0-beta.1)
2.xfrom 5.0.08.x (through router@2.0.0-beta.2)

Table of Contents

Installation

npm install @gpa/extract-params-from-path

Requirements

Usage

import { ExtractParamsFromPath } from '@gpa/extract-params-from-path';

function router<Path extends string>(path: Path, handler: (request: { params: ExtractParamsFromPath<Path> }) => void) {}

router('/path/:pathParam', (req) => {
  // req.params is { pathParam: string }
});

API

ExtractParamsFromPath<Path extends string>

<Path>

Type: string

The path to extract the parameters from.

FAQs

Package last updated on 07 Oct 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.