1.0.2 • Published 6 years ago

koa-csv v1.0.2

Weekly downloads
4
License
Apache-2.0
Repository
github
Last release
6 years ago

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

NameValue
namevalue
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