koa-csv

1.0.2 • Public • Published

koa-csv

NPM version Build status Test coverage License Downloads

CSV files serving as json API middleware for koa

Usage Example

const Koa = require('koa')
const app = new Koa()
app.use(require('koa-csv')(root, opts))
  • root root directory string
  • opts option object

Request Example

for test.csv like this

Name Value
name value
GET /test.csv
[{
    "Name": "name",
    "Value": "value"
}]
GET /test.csv?axis=col
{
    "Name": ["name"],
    "Value": ["value"]
}

Options

  • trim whether or not trim each cell, default true
  • axis default is row, csv will be converted to an array of objects representing each line in csv, if axis is col, csv will be converted to an object, each property representing column in csv
  • delimiter csv delimiter, default ,
  • prefix set the prefix of request path to match
  • lsdir enable lsdir if path is a dir, default false

TODO

  • gzip support

Readme

Keywords

Package Sidebar

Install

npm i koa-csv

Weekly Downloads

4

Version

1.0.2

License

Apache-2.0

Unpacked Size

19.7 kB

Total Files

10

Last publish

Collaborators

  • quicksort