Skip to content

Commit

Permalink
Update Prettier and related config.
Browse files Browse the repository at this point in the history
  • Loading branch information
krasivyy3954 committed May 23, 2020
1 parent cfebfe5 commit e578b18
Show file tree
Hide file tree
Showing 22 changed files with 1,129 additions and 1,080 deletions.
3 changes: 1 addition & 2 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"proseWrap": "never",
"singleQuote": true,
"semi": false
"singleQuote": true
}
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

### Patch

- Updated Prettier related package scripts.
- Configured Prettier option `semi` to the default, `true`.
- Ensure GitHub Actions run on pull request.
- Minor JSDoc wording tweak for consistency.

Expand Down
18 changes: 9 additions & 9 deletions lib/GraphQLUpload.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'
'use strict';

const { GraphQLScalarType, GraphQLError } = require('graphql')
const Upload = require('./Upload')
const { GraphQLScalarType, GraphQLError } = require('graphql');
const Upload = require('./Upload');

/**
* A GraphQL `Upload` scalar that can be used in a
Expand Down Expand Up @@ -62,13 +62,13 @@ module.exports = new GraphQLScalarType({
name: 'Upload',
description: 'The `Upload` scalar type represents a file upload.',
parseValue(value) {
if (value instanceof Upload) return value.promise
throw new GraphQLError('Upload value invalid.')
if (value instanceof Upload) return value.promise;
throw new GraphQLError('Upload value invalid.');
},
parseLiteral(ast) {
throw new GraphQLError('Upload literal unsupported.', ast)
throw new GraphQLError('Upload literal unsupported.', ast);
},
serialize() {
throw new GraphQLError('Upload serialization unsupported.')
}
})
throw new GraphQLError('Upload serialization unsupported.');
},
});
18 changes: 9 additions & 9 deletions lib/Upload.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use strict'
'use strict';

/**
* A file expected to be uploaded as it has been declared in the `map` field of
Expand Down Expand Up @@ -28,7 +28,7 @@ module.exports = class Upload {
* @name Upload#resolve
* @param {FileUpload} file File upload details.
*/
this.resolve = file => {
this.resolve = (file) => {
/**
* The file upload details, available when the
* [upload promise]{@link Upload#promise} resolves. This should only be
Expand All @@ -37,10 +37,10 @@ module.exports = class Upload {
* @name Upload#file
* @type {undefined|FileUpload}
*/
this.file = file
this.file = file;

resolve(file)
}
resolve(file);
};

/**
* Rejects the upload promise with an error. This should only be
Expand All @@ -49,11 +49,11 @@ module.exports = class Upload {
* @name Upload#reject
* @param {object} error Error instance.
*/
this.reject = reject
})
this.reject = reject;
});

// Prevent errors crashing Node.js, see:
// https://github.com/nodejs/node/issues/20392
this.promise.catch(() => {})
this.promise.catch(() => {});
}
}
};
4 changes: 2 additions & 2 deletions lib/constants.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use strict'
'use strict';

/**
* Official [GraphQL multipart request spec](https://github.com/jaydenseric/graphql-multipart-request-spec)
Expand All @@ -9,4 +9,4 @@
* @ignore
*/
exports.SPEC_URL =
'https://github.com/jaydenseric/graphql-multipart-request-spec'
'https://github.com/jaydenseric/graphql-multipart-request-spec';
36 changes: 18 additions & 18 deletions lib/graphqlUploadExpress.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'
'use strict';

const defaultProcessRequest = require('./processRequest')
const defaultProcessRequest = require('./processRequest');

/**
* Creates [Express](https://expressjs.com) middleware that processes
Expand Down Expand Up @@ -35,26 +35,26 @@ module.exports = function graphqlUploadExpress({
...processRequestOptions
} = {}) {
return function graphqlUploadExpressMiddleware(request, response, next) {
if (!request.is('multipart/form-data')) return next()
if (!request.is('multipart/form-data')) return next();

const finished = new Promise(resolve => request.on('end', resolve))
const { send } = response
const finished = new Promise((resolve) => request.on('end', resolve));
const { send } = response;

response.send = (...args) => {
finished.then(() => {
response.send = send
response.send(...args)
})
}
response.send = send;
response.send(...args);
});
};

processRequest(request, response, processRequestOptions)
.then(body => {
request.body = body
next()
})
.catch(error => {
if (error.status && error.expose) response.status(error.status)
next(error)
.then((body) => {
request.body = body;
next();
})
}
}
.catch((error) => {
if (error.status && error.expose) response.status(error.status);
next(error);
});
};
};
18 changes: 9 additions & 9 deletions lib/graphqlUploadKoa.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'
'use strict';

const defaultProcessRequest = require('./processRequest')
const defaultProcessRequest = require('./processRequest');

/**
* Creates [Koa](https://koajs.com) middleware that processes
Expand Down Expand Up @@ -35,19 +35,19 @@ module.exports = function graphqlUploadKoa({
...processRequestOptions
} = {}) {
return async function graphqlUploadKoaMiddleware(ctx, next) {
if (!ctx.request.is('multipart/form-data')) return next()
if (!ctx.request.is('multipart/form-data')) return next();

const finished = new Promise(resolve => ctx.req.on('end', resolve))
const finished = new Promise((resolve) => ctx.req.on('end', resolve));

try {
ctx.request.body = await processRequest(
ctx.req,
ctx.res,
processRequestOptions
)
await next()
);
await next();
} finally {
await finished
await finished;
}
}
}
};
};
8 changes: 4 additions & 4 deletions lib/ignoreStream.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use strict'
'use strict';

/**
* Safely ignores a Node.js readable stream.
Expand All @@ -9,8 +9,8 @@
*/
module.exports = function ignoreStream(stream) {
// Prevent an unhandled error from crashing the process.
stream.on('error', () => {})
stream.on('error', () => {});

// Waste the stream.
stream.resume()
}
stream.resume();
};
12 changes: 6 additions & 6 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict'
'use strict';

exports.GraphQLUpload = require('./GraphQLUpload')
exports.processRequest = require('./processRequest')
exports.graphqlUploadKoa = require('./graphqlUploadKoa')
exports.graphqlUploadExpress = require('./graphqlUploadExpress')
exports.Upload = require('./Upload')
exports.GraphQLUpload = require('./GraphQLUpload');
exports.processRequest = require('./processRequest');
exports.graphqlUploadKoa = require('./graphqlUploadKoa');
exports.graphqlUploadExpress = require('./graphqlUploadExpress');
exports.Upload = require('./Upload');

/**
* File upload details that are only available after the file’s field in the
Expand Down

0 comments on commit e578b18

Please sign in to comment.