Socket
Socket
Sign inDemoInstall

express-graphql

Package Overview
Dependencies
11
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.0 to 0.1.1

31

dist/index.js

@@ -45,8 +45,2 @@

return function (request, response) {
// GraphQL HTTP only supports GET and POST methods.
if (request.method !== 'GET' && request.method !== 'POST') {
return response.status(405).set('Allow', 'GET, POST');
}
// Get GraphQL options given this request.

@@ -60,9 +54,15 @@

// GraphQL HTTP only supports GET and POST methods.
if (request.method !== 'GET' && request.method !== 'POST') {
response.set('Allow', 'GET, POST');
return sendError(response, (0, _httpErrors2['default'])(405, 'GraphQL only supports GET and POST requests.'), pretty);
}
// Parse the Request body.
(0, _parseBody.parseBody)(request, function (error, data) {
(0, _parseBody.parseBody)(request, function (error) {
var data = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
// Format any request errors the same as GraphQL errors.
if (error) {
var errorResponse = { errors: [(0, _graphqlError.formatError)(error)] };
return response.status(error.status || 500).set('Content-Type', 'text/json').send(JSON.stringify(errorResponse, null, pretty ? 2 : 0));
return sendError(response, error, pretty);
}

@@ -72,3 +72,3 @@

var _getGraphQLParams = getGraphQLParams(request, data || {});
var _getGraphQLParams = getGraphQLParams(request, data);

@@ -119,2 +119,5 @@ var query = _getGraphQLParams.query;

var query = request.query.query || data.query;
if (!query) {
throw (0, _httpErrors2['default'])(400, 'Must provide query string.');
}

@@ -136,2 +139,10 @@ // Parse the variables if needed.

}
/**
* Helper for formatting errors
*/
function sendError(response, error, pretty) {
var errorResponse = { errors: [(0, _graphqlError.formatError)(error)] };
response.status(error.status || 500).set('Content-Type', 'text/json').send(JSON.stringify(errorResponse, null, pretty ? 2 : 0));
}
module.exports = exports['default'];

@@ -138,0 +149,0 @@

@@ -24,4 +24,2 @@

var _iconvLite = require('iconv-lite');
var _rawBody = require('raw-body');

@@ -124,3 +122,3 @@

if (err) {
return next(err.type === 'encoding.unsupported' ? (0, _httpErrors2['default'])(415, 'Unsupported charset "' + charset.toUpperCase() + '".') : setErrorHttpStatus(err, 400));
return next(err.type === 'encoding.unsupported' ? (0, _httpErrors2['default'])(415, 'Unsupported charset "' + charset.toUpperCase() + '".') : (0, _httpErrors2['default'])(400, 'Invalid body: ' + err.message + '.'));
}

@@ -130,6 +128,5 @@

// Decode and parse body.
var bodyString = typeof body === 'string' ? body : (0, _iconvLite.decode)(body, charset);
return next(null, parseFn(bodyString));
return next(null, parseFn(body));
} catch (error) {
return next(setErrorHttpStatus(error, 400));
return next(error);
}

@@ -150,10 +147,2 @@ });

throw (0, _httpErrors2['default'])(415, 'Unsupported content-encoding "' + encoding + '".');
}
// Set an http status on an error object, if one does not exist.
function setErrorHttpStatus(error, status) {
if (!error.status && !error.statusCode) {
error.status = error.statusCode = status;
}
return error;
}
{
"name": "express-graphql",
"version": "0.1.0",
"version": "0.1.1",
"description": "Create a GraphQL HTTP server with Express.",

@@ -37,3 +37,3 @@ "contributors": [

"scripts": {
"prepublish": "npm test && npm run build",
"prepublish": ". ./resources/prepublish.sh",
"test": "npm run lint && npm run check && npm run testonly",

@@ -45,3 +45,5 @@ "testonly": "mocha $npm_package_options_mocha",

"watch": "babel --optional runtime resources/watch.js | node",
"coveralls": "babel-node node_modules/.bin/isparta cover --root src --report lcovonly node_modules/.bin/_mocha -- $npm_package_options_mocha && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js"
"cover": "babel-node node_modules/.bin/isparta cover --root src --report html node_modules/.bin/_mocha -- $npm_package_options_mocha",
"cover:lcov": "babel-node node_modules/.bin/isparta cover --root src --report lcovonly node_modules/.bin/_mocha -- $npm_package_options_mocha",
"preversion": "npm test"
},

@@ -51,3 +53,2 @@ "dependencies": {

"http-errors": "~1.3.1",
"iconv-lite": "~0.4.11",
"raw-body": "~2.1.2"

@@ -72,2 +73,3 @@ },

"mocha": "2.2.5",
"multer": "^1.0.3",
"sane": "1.1.3",

@@ -74,0 +76,0 @@ "supertest": "1.0.1",

GraphQL Express Middleware
==========================
Create a GraphQL HTTP server with Express.
[![Build Status](https://travis-ci.org/graphql/express-graphql.svg)](https://travis-ci.org/graphql/express-graphql)
[![Coverage Status](https://coveralls.io/repos/graphql/express-graphql/badge.svg?branch=master&service=github)](https://coveralls.io/github/graphql/express-graphql?branch=master)
Create a GraphQL HTTP server with [Express](http://expressjs.com).
```sh

@@ -7,0 +10,0 @@ npm install --save express-graphql

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc