Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kbarbounakis/most-web-csv
Most Web Framework CSV Handler
https://github.com/kbarbounakis/most-web-csv
Last synced: 1 day ago
JSON representation
Most Web Framework CSV Handler
- Host: GitHub
- URL: https://github.com/kbarbounakis/most-web-csv
- Owner: kbarbounakis
- License: bsd-3-clause
- Created: 2015-09-14T07:21:01.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2018-02-09T07:45:12.000Z (almost 7 years ago)
- Last Synced: 2024-11-04T11:03:18.548Z (13 days ago)
- Language: JavaScript
- Size: 10.7 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# @themost/csv
Most Web Framework CSV Handler#### Install
npm install @themost/csv
Note: If you want to install the previous version (0.1.x) of most-web-csv module use:
npm install most-web-csv
#### UsageUse this handler by extending HttpDataController class:
//# http-data-controller-extensions.js
import {HttpDataController} from '@themost/web/controllers/data';
Object.assign(HttpDataController.prototype, {
/**
* @this HttpDataController
*/
csv:(data)=> {
return new HttpCsvResult(data);
}
});//# server.js
import './http-data-controller-extensions';
...
...Register default route for /[controller]/[action].csv requests in config/routes.json:
...
{ "url":"/:controller/:action.json", "mime":"application/json" },
{ "url":"/:controller/:action.xml" },
{ "url":"/:controller/:action.csv", "mime":"application/csv" },
...and finally add csv content type in application content types (config/app.json#mimes)
...
{
"extension": ".ttf",
"type": "application/octet-stream"
},
...
{
"extension": ".csv",
"type": "application/csv"
}
...