Socket
Socket
Sign inDemoInstall

hapi-csv

Package Overview
Dependencies
3
Maintainers
3
Versions
41
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.1 to 3.0.2

8

lib/index.js

@@ -24,3 +24,3 @@ 'use strict';

if (route.settings.response.schema) {
internals.routeMap.set(route.path, route.settings.response.schema);
internals.routeMap.set(internals.createRouteMethodString(route.path, route.method), route.settings.response.schema);
}

@@ -64,4 +64,4 @@ });

if (preferedType && internals.routeMap.has(request.route.path)) {
const schema = internals.routeMap.get(request.route.path);
if (preferedType && internals.routeMap.has(internals.createRouteMethodString(request.route.path, request.route.method))) {
const schema = internals.routeMap.get(internals.createRouteMethodString(request.route.path, request.route.method));
const csv = internals.schemaToCsv(schema, request.response.source, options.separator, options.resultKey);

@@ -254,1 +254,3 @@

};
internals.createRouteMethodString = (route, method) => route + '_' + method;

@@ -0,0 +0,0 @@ The MIT License (MIT)

{
"name": "hapi-csv",
"version": "3.0.1",
"version": "3.0.2",
"description": "Hapi plugin for converting a Joi response schema and dataset to csv",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -0,0 +0,0 @@ # Hapi-csv [![Build Status](https://travis-ci.org/Salesflare/hapi-csv.svg?branch=master)](https://travis-ci.org/Salesflare/hapi-csv)

@@ -45,2 +45,6 @@ 'use strict';

const userCSV = 'first_name,last_name,age,\n"firstName","lastName","25",';
const postUser = {
first_name: user.first_name
};
const postUserCSV = 'first_name,\n"firstName",';
const testResponseSchema = Joi.object().keys({

@@ -51,2 +55,5 @@ first_name: Joi.string(),

});
const testPostResponseSchema = Joi.array().items(Joi.object().keys({
first_name: Joi.string()
})).single();

@@ -70,3 +77,16 @@ before((done) => {

}
}, {
},
{
method: 'POST',
path: '/user',
config: {
handler: function (request, reply) {
return reply(postUser);
},
response: {
schema: testPostResponseSchema
}
}
}, {
method: 'GET',

@@ -267,2 +287,20 @@ path: '/userWithoutSchema',

});
it('Replies with the right response when there are similar routes with different methods', (done) => {
return simpleServer.inject({
method: 'POST',
url: '/user',
headers: {
'Accept': 'text/csv'
}
}, (res) => {
expect(res.result).to.equal(postUserCSV);
expect(res.headers['content-type']).to.equal('text/csv; charset=utf-8');
expect(res.headers['content-disposition']).to.equal('attachment;');
return done();
});
});
});

@@ -269,0 +307,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc