https://github.com/scalajs-io/express-csv
express-csv provides response csv easily to express.
https://github.com/scalajs-io/express-csv
csv express expressjs node nodejs npm npm-package
Last synced: about 1 year ago
JSON representation
express-csv provides response csv easily to express.
- Host: GitHub
- URL: https://github.com/scalajs-io/express-csv
- Owner: scalajs-io
- License: apache-2.0
- Created: 2017-02-11T14:30:28.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2019-06-17T23:08:26.000Z (almost 7 years ago)
- Last Synced: 2025-01-17T22:42:41.650Z (about 1 year ago)
- Topics: csv, express, expressjs, node, nodejs, npm, npm-package
- Language: Scala
- Size: 15.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
ExpressCSV API for Scala.js
================================
[express-csv](https://www.npmjs.com/package/express-csv) provides response csv easily to express.
### Description
_____ ____ ______ __
| ____|_ ___ __ _ __ ___ ___ ___ / ___/ ___\ \ / /
| _| \ \/ / '_ \| '__/ _ \/ __/ __| | | \___ \\ \ / /
| |___ > <| |_) | | | __/\__ \__ \ | |___ ___) |\ V /
|_____/_/\_\ .__/|_| \___||___/___/ \____|____/ \_/
|_|
Express CSV provides response CSV easily to Express.
### Build Dependencies
* [SBT v1.2.x](http://www.scala-sbt.org/download.html)
### Build/publish the SDK locally
```bash
$ sbt clean publish-local
```
### Running the tests
Before running the tests the first time, you must ensure the npm packages are installed:
```bash
$ npm install
```
Then you can run the tests:
```bash
$ sbt test
```
### Examples
##### A simple Express Server with CSV
```scala
import io.scalajs.npm.express._
import io.scalajs.npm.express.csv._
import scalajs.js
// load the Express modules
val app = Express()
ExpressCSV
app.get("/", { (_: Request, res: Response with CSVResponse) =>
res.csv(
js.Array(
js.Array("a", "b", "c"),
js.Array("d", "e", "f")
))
})
.listen(8080)
```
##### A simple client example
```scala
import io.scalajs.nodejs.http._
import io.scalajs.npm.express.csv._
Http.get("http://localhost:8080/", { response: ServerResponse =>
response.onData { chunk =>
val data = chunk.toString().split('\n').map(_.trim).mkString("|")
println(data) // "a","b","c"|"d","e","f"
}
})
```
### Artifacts and Resolvers
To add the `ExpressCSV` binding to your project, add the following to your build.sbt:
```sbt
libraryDependencies += "io.scalajs.npm" %%% "express-csv" % "0.5.0"
```
Optionally, you may add the Sonatype Repository resolver:
```sbt
resolvers += Resolver.sonatypeRepo("releases")
```