@flitz/params
TypeScript icon, indicating that this package has built-in type declarations

2.1.0 • Public • Published

npm supported flitz version last build PRs Welcome

@flitz/params

Extracts path parameters and makes them available in a flitz request.

Install

Run

npm install --save @flitz/params

from the folder, where your package.json is stored.

Usage

const flitz = require('flitz');
const params = require('@flitz/params');

const run = async () => {
  const app = flitz();

  //        👇👇👇
  app.post( params('/foo/:bar/:baz?'), async (req, res) => {
    res.write('Submitted params: ' + JSON.stringify(req.params, null, 2));
    res.end();
  });

  await app.listen(3000);
};

run();

Or the TypeScript way:

import flitz from 'flitz';
import { params } from '@flitz/params';

const run = async () => {
  const app = flitz();

  //        👇👇👇
  app.post( params('/foo/:bar/:baz?'), async (req, res) => {
    res.write('Submitted params: ' + JSON.stringify(req.params, null, 2));
    res.end();
  });

  await app.listen(3000);
};

run();

TypeScript

TypeScript is optionally supported. The module contains its own definition files.

Credits

The module makes use of:

License

MIT © Marcel Kloubert

Package Sidebar

Install

npm i @flitz/params

Weekly Downloads

1

Version

2.1.0

License

MIT

Unpacked Size

11.3 kB

Total Files

9

Last publish

Collaborators

  • mkloubert
  • mkloubertego