This file contains hidden or 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
| const F = require('fluture') | |
| const {create, env} = require ('sanctuary'); | |
| const {env: flutureEnv} = require ('fluture-sanctuary-types'); | |
| const S = create ({checkTypes: true, env: env.concat (flutureEnv)}); | |
| const getName = id => new Promise(resolve => { | |
| console.log(id) | |
| setTimeout(() => resolve('Franz'), 3000) | |
| }) |
This file contains hidden or 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
| const R = require('ramda') | |
| function quicksort(list) { | |
| return R.ifElse( | |
| R.pipe(R.length, R.gt(2)), | |
| R.identity, | |
| list => { | |
| const [pivot, ...rest] = list | |
| return R.pipe( | |
| R.partition(R.gt(pivot)), |
This file contains hidden or 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
| events {} | |
| http { | |
| upstream webapp { | |
| server host.docker.internal:3000; # development only | |
| } | |
| server { | |
| listen 80; | |
| server_name localhost; |
This file contains hidden or 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
| // For simplicity, error handling is not included | |
| const axios = require('axios') | |
| const AWS = require('aws-sdk'); | |
| const region = process.env['AwsRegion'] | |
| AWS.config.update({region}); | |
| const url = process.env['ExchangeRateURL'] | |
| const bucket = process.env['S3Bucket'] |
This file contains hidden or 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: | |
| AwsRegion: | |
| Type: String | |
| Default: us-east-1 | |
| # This bucket stores the lambda function package | |
| LambdaCodeBucket: | |
| Type: String | |
| Default: my-lambda | |
| LambdaCodeKey: |
This file contains hidden or 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
| async function signUp(email, password) { | |
| try { | |
| const cognito = new AWS.CognitoIdentityServiceProvider() | |
| await cognito.adminCreateUser({ | |
| UserPoolId: process.env.USER_POOL_ID, | |
| Username: email, | |
| MessageAction: 'SUPPRESS', | |
| TemporaryPassword: password, | |
| }).promise() |
This file contains hidden or 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
| async function login(email, password) { | |
| try { | |
| const cognito = new AWS.CognitoIdentityServiceProvider() | |
| return await cognito.adminInitiateAuth({ | |
| AuthFlow: 'ADMIN_NO_SRP_AUTH', | |
| ClientId: process.env.CLIENT_ID, | |
| UserPoolId: process.env.USER_POOL_ID, | |
| AuthParameters: { | |
| USERNAME: email, | |
| PASSWORD: password |
This file contains hidden or 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
| { | |
| "Version": "2012-10-17", | |
| "Statement": [{ | |
| "Effect": "Allow", | |
| "Principal": {"Federated": "cognito-identity.amazonaws.com"}, | |
| "Action": "sts:AssumeRoleWithWebIdentity", | |
| "Condition": { | |
| "StringEquals": {"cognito-identity.amazonaws.com:aud": "<IDENTITY_POOL_ID>"}, | |
| "ForAnyValue:StringLike": {"cognito-identity.amazonaws.com:amr": "authenticated"} | |
| } |
This file contains hidden or 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
| { | |
| "Version": "2012-10-17", | |
| "Statement": [ | |
| { | |
| "Effect": "Allow", | |
| "Action": [ | |
| "s3:GetObject", | |
| "s3:PutObject", | |
| "s3:DeleteObject" | |
| ], |
This file contains hidden or 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
| async function getUserCredentials(idToken) { | |
| const cognitoidentity = new AWS.CognitoIdentity() | |
| const providerName = `cognito-idp.${process.env.AWS_REGION}.amazonaws.com/${process.env.USER_POOL_ID}` | |
| let response = await cognitoidentity.getId({ | |
| IdentityPoolId: process.env.IDENTITY_POOL_ID, | |
| Logins: { | |
| [providerName]: idToken | |
| } | |
| }).promise() |