1.1.0 • Published 10 months ago

body-parser-csv v1.1.0

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

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:

yarn

Compilation of typescript code

To compile typescript code into js one-time

yarn run build

or run this, to watch all changes

yarn 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

or

yarn add 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 yarn run generate-docs. TypeDoc source code documentation is located in docs/typedoc.

Contribution guidelines

Please read CONTRIBUTING.md.

Troubleshooting

Contact benak@operatorict.cz or vycpalek@operatorict.cz