1.0.2 • Published 6 years ago
koa-csv v1.0.2
koa-csv
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 stringopts
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, defaulttrue
axis
default isrow
, csv will be converted to an array of objects representing each line in csv, ifaxis
iscol
, csv will be converted to an object, each property representing column in csvdelimiter
csv delimiter, default,
prefix
set the prefix of request path to matchlsdir
enable lsdir if path is a dir, default false
TODO
- gzip support