1.0.1 • Published 10 months ago

@gpa/extract-params-from-path v1.0.1

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
10 months ago

@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

  1. Installation
  2. Requirements
  3. Usage
  4. API

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\

\

Type: string

The path to extract the parameters from.

2.0.0-alpha.3

10 months ago

1.0.1

10 months ago

2.0.0-alpha.2

10 months ago

2.0.0-alpha.1

11 months ago

1.0.0

11 months ago