express-csv-middleware

Express middleware that parse text/csv content into array or object.

Usage no npm install needed!

<script type="module">
  import expressCsvMiddleware from 'https://cdn.skypack.dev/express-csv-middleware';
</script>

README

NPM version"> Build Status Dependency Status

Express middleware that parse text/csv content into array or object.

Install

$ npm install --save express-csv-middleware

Usage

var expressCsv = require('express-csv-middleware');

var bodyParserOptions = {
  // https://github.com/expressjs/body-parser#bodyparsertextoptions
};
var csvOptions = {
  // http://csv.adaltas.com/parse/
  // http://csv.adaltas.com/stringify/
};

app.use(expressCsv(bodyParserOptions, csvOptions));

// POST with Content-Type: text/csv
app.post(function(req, res) {
  console.log(req.body);    // [['header', 'row'], ['body', 'rows'], ...]
  app.csv(req.body);        // Respond with Content-Type: text/csv
})

License

MIT © Greg Wang