Skip to content

Instantly share code, notes, and snippets.

🎧
Groovin'

Pat Migliaccio patmigliaccio

🎧
Groovin'
Block or report user

Report or block patmigliaccio

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@patmigliaccio
patmigliaccio / now-secrets-json.js
Created May 12, 2019
Adds secret keys from local JSON files as Base64 to `now` secrets.
View now-secrets-json.js
const fs = require('fs');
const GOOGLE_APPLICATION_CREDENTIALS = 'keys/google_application_credentials.json';
/**
* Adds secret keys from local JSON files as Base64 to `now` secrets.
*
* e.g. `node now-secrets-json.js'
*/
function main() {
@patmigliaccio
patmigliaccio / resolving-nested-promises-6.5.js
Created Apr 4, 2019
patmigliaccio.com/resolving-nested-promises 4/4/19
View resolving-nested-promises-6.5.js
const resolvedActiveUsersFullComments = await Promise.all(activeUsersFullComments);
@patmigliaccio
patmigliaccio / resolving-nested-promises-10.js
Created Apr 4, 2019
patmigliaccio.com/resolving-nested-promises 4/4/19
View resolving-nested-promises-10.js
5 users * 1 comment = 5 requests
5 users * 2 comments = 10 requests
5 users * 10 comments = 50 requests
@patmigliaccio
patmigliaccio / resolving-nested-promises-9.js
Created Apr 4, 2019
patmigliaccio.com/resolving-nested-promises 4/4/19
View resolving-nested-promises-9.js
function resolveUsers(users) {
const resolveComments = createCommentsResolver();
return Promise.all(
users.map(user => {
return resolveComments(user)
})
);
}
@patmigliaccio
patmigliaccio / resolving-nested-promises-8.js
Created Apr 4, 2019
patmigliaccio.com/resolving-nested-promises 4/4/19
View resolving-nested-promises-8.js
function resolveUsers(users) {
return Promise.all(
users.map(user => {
return resolveComments(user)
})
);
}
async function resolveComments(user) {
user.comments = await Promise.all(
@patmigliaccio
patmigliaccio / resolving-nested-promises-7.js
Created Apr 4, 2019
patmigliaccio.com/resolving-nested-promises 4/4/19
View resolving-nested-promises-7.js
[
{
id: '8190834',
commentIds: [ '0002434', '0002437', '0002440' ],
comments: [
{
id: '0002434',
content: 'Awesome post!'
},
{
@patmigliaccio
patmigliaccio / resolving-nested-promises-6.js
Created Apr 4, 2019
patmigliaccio.com/resolving-nested-promises 4/4/19
View resolving-nested-promises-6.js
[
Promise { <pending> },
Promise { <pending> }
]
@patmigliaccio
patmigliaccio / resolving-nested-promises-5.js
Created Apr 4, 2019
patmigliaccio.com/resolving-nested-promises 4/4/19
View resolving-nested-promises-5.js
function resolveComments(user) {
return Promise.all(
user.commentIds.map(commentId => {
return comments.getCommentById(commentId)
})
);
}
const activeUsers = await post.getActiveUsers();
const activeUsersFullComments = activeUsers.map(async user => {
@patmigliaccio
patmigliaccio / resolving-nested-promises-4.js
Created Apr 4, 2019
patmigliaccio.com/resolving-nested-promises 4/4/19
View resolving-nested-promises-4.js
[
{
id: '8190834',
commentIds: [ '0002434', '0002437', '0002440' ],
comments: [
Promise { <pending> },
Promise { <pending> },
Promise { <pending> }
]
},
@patmigliaccio
patmigliaccio / resolving-nested-promises-3.js
Created Apr 4, 2019
patmigliaccio.com/resolving-nested-promises 4/4/19
View resolving-nested-promises-3.js
const activeUsers = await post.getActiveUsers();
const activeUsersComments = activeUsers.map(user => {
user.comments = user.commentIds.map(async commentId => {
return await comments.getCommentById(commentId)
});
return user;
});
You can’t perform that action at this time.