This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export.handler = function (evt, ctx, callback) { | |
Promise.resolve() | |
.then(() => { | |
// Unmodified handler execution | |
}) | |
.then(koaResponse => { | |
// Unmodified success handling | |
}) | |
.catch(e => { | |
if (!e) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class InvokeManager { | |
finish(err, data, waitToFinish) { | |
if (this._result === undefined) { | |
if (err == null) { | |
this._result = [null, JSON.stringify(isUndefined(data) ? null : data)]; | |
} else { | |
let errType = this._faulted ? 'unhandled' : 'handled'; | |
this._result = [errType, stringifyError(errType, err)]; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
process.on('beforeExit', () => invokeManager.finish(null, null, false)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function someAsyncFunction () { | |
return new Promise(function () { | |
// This is a bad promise that never resolves | |
}); | |
} | |
someAsyncFunction() | |
.then(function () { | |
console.log('Done'); | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function safePromise (promise, timeout) { | |
let slowOpId; | |
const slowLoggingPromise = pFinally(promise, function () { | |
if (slowOpId) { | |
log.warn({slowOpId, itemKey}, 'The Promise eventually resolved'); | |
} | |
}); | |
// Don't wait on longer than `timeout` ms for the Promise |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is the attribute that continuation local storage uses to hold onto | |
// the current context. The value comes from https://github.com/othiym23/node-continuation-local-storage/blob/fc770288979f6050e4371c1e1b44d2b76b233664/context.js#L11 | |
const CLS_CONTEXT_ATTRIBUTE = 'error@context'; | |
// A formatError function that can be used with | |
// https://www.apollographql.com/docs/apollo-server/features/errors#for-the-client-response | |
function formatError (err) { | |
// The continuation-local-storage module attaches a context attribute to | |
// errors so that the context can be resolved from errors. The attribute | |
// is enumerable by default and so it gets included in GraphQL error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
IFS='|' | |
help_output () { | |
echo "usage: amplify-push <--environment|-e <name>> <--simple|-s>" | |
echo " --environment The name of the Amplify environment to use" | |
echo " --simple Optional simple flag auto-includes stack info from env cache" | |
exit 1 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import awsconfig from "./aws-exports"; | |
import Amplify from "@aws-amplify/core"; | |
// Find the User Pool ID for your production deployment in | |
// the AWS Console | |
if (awsconfig.aws_user_pools_id === "us-east-1_M7n6RNrq9") { | |
awsconfig.oauth.domain = "auth.yourdomain.com; | |
} | |
Amplify.configure(awsconfig); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"auth": { | |
"domain": { | |
"providerPlugin": "awscloudformation", | |
"dependsOn": [ | |
{ | |
"category": "auth", | |
"resourceName": "CognitoResource", | |
"attributes": [ | |
"UserPoolId" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion: 2010-09-09 | |
Parameters: | |
env: | |
Type: String | |
authCognitoResourceUserPoolId: | |
Type: String | |
Mappings: | |
CustomAuthDomains: |