npm.io
1.2.1 • Published 4 months ago

body-parser-csv

Licence
MIT
Version
1.2.1
Deps
6
Size
12 kB
Vulns
0
Weekly
148
DeprecatedThis package is deprecated

body-parser-csv

This package is inspired by body-parser-xml and is using fast-csv for parsing.

Developed by http://operatorict.cz

Prerequisites

Installation

Install Node

Install all npm modules using command:

npm install

Compilation of typescript code

To compile typescript code into js one-time

npm run build

or run this, to watch all changes

npm run build-watch

from the application's root directory.

Usage

In your project's package.json set dependency to body-parser-csv

npm install body-parser-csv --save

Then import module, e.g.

const bodyParser = require("body-parser");
require("body-parser-csv")(bodyParser);

You can then use body-parser-csv the same way as you would use the body-parser-xml, with csv parsing options inside of the csvParseOptions parameter.

this.express.use(
    bodyParser.csv({
        csvParseOptions: {
            fastcsvParams: {
                headers: true,
                trim: true,
            },
            subscribe: ((json: any) => {
                // some line transformation
                return json;
            }),
        },
        limit: "15MB",
    })
);

Documentation

For generating documentation run npm run generate-docs. TypeDoc source code documentation is located in docs/typedoc.

Contribution guidelines

Please read CONTRIBUTING.md.

Troubleshooting

Contact benak@operatorict.cz

Keywords