@flitz/params
v2.1.0
Published
Extracts path parameters and makes them available in a flitz request.
Downloads
17
Maintainers
Readme
@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