2.1.0 • Published 4 years ago

@flitz/params v2.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

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

2.1.0

4 years ago

1.0.0

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

0.2.1

4 years ago

0.1.2

4 years ago

0.2.0

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago