Socket
Socket
Sign inDemoInstall

hapi-csv

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hapi-csv

Hapi plugin for converting a Joi response schema and dataset to csv


Version published
Weekly downloads
93
increased by27.4%
Maintainers
1
Weekly downloads
 
Created
Source

What

Converts the response to csv based on the defined response schema when the Accept-header includes text/csv

How

npm install hapi-csv

Register the hapi-csv plugin on the server

server.register({
	register: require('hapi-csv'),
	options: {
	}
}, function (err) {
	if (err) console.log(err);
	...
});

When you have a route on which a response schema is defined, like in the example below, the plugin will convert the response to csv when the Accept-header includes text/csv

const userResponseSchema = Joi.array().required().items({
	user: Joi.object().keys({
		id: Joi.number().required(),
		picture: Joi.string().allow('').allow(null),
		name: Joi.string().allow('').allow(null)
	}).allow(null)
})

const routes = [
	{
		method: 'GET',
		path: '/users',
		handler: Users.getAll,
		config: {
			response: {
				schema: userResponseSchema
			}
		}
	}
]

Keywords

FAQs

Package last updated on 10 Jul 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc