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 { | |
_Record, | |
Dimension, | |
MeasureValue, | |
MeasureValueType, TimestreamWriteClient, | |
WriteRecordsCommand, WriteRecordsCommandOutput, | |
WriteRecordsRequest, | |
} from '@aws-sdk/client-timestream-write'; | |
export const getInsertRecordParameterToTimeStream = ( |
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 { RemovalPolicy } from 'aws-cdk-lib'; | |
import { CfnDatabase, CfnTable } from 'aws-cdk-lib/aws-timestream'; | |
import { Construct } from 'constructs'; | |
export interface TimeStreamConstructProps { | |
databaseName: string; | |
tableName: string; | |
} | |
export class TimeStreamConstruct extends Construct { |
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 const handler = async (event:any) => { | |
// Get Authorization Header | |
const jwtToken = getSafeOrThrow(event.headers.Authorization,'Missing authorizer on private API'); | |
// Retrieve the email from Stytch User Pool | |
const email = await fromJwtTokenToUserEmail(jwtToken); | |
// Get user from the database | |
const user = await getUserFromDatabase(email); |
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 const getStytchLoginLambdaIntegration = ( | |
stack: Construct, | |
id:string, | |
options:InfrastructureOptions) => { | |
const loginFunction = new NodejsFunction(stack, id, { | |
architecture: Architecture.ARM_64, | |
entry: `${__dirname}/login.ts`, | |
logRetention: RetentionDays.ONE_WEEK, | |
timeout: Duration.minutes(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
export const getStytchTokenFromSessionIdLambdaIntegration = ( | |
stack: Construct, | |
id:string, | |
options:InfrastructureOptions) => { | |
const getToken = new NodejsFunction(stack, id, { | |
architecture: Architecture.ARM_64, | |
entry: `${__dirname}/token.ts`, | |
logRetention: RetentionDays.ONE_WEEK, | |
timeout: Duration.minutes(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
export const getStytchRegisterLambdaIntegration = ( | |
stack: Construct, | |
id:string, | |
options:InfrastructureOptions) => { | |
const registerFunction = new NodejsFunction(stack, id, { | |
architecture: Architecture.ARM_64, | |
entry: `${__dirname}/register.ts`, | |
logRetention: RetentionDays.ONE_WEEK, | |
timeout: Duration.minutes(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
<div #magic_stytch_login> | |
</div> |
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 const getStytchAuthorizerIntegrationLambda = ( | |
stack: Construct, | |
id:string, | |
options:InfrastructureOptions) => { | |
const authorizerFn = new NodejsFunction(stack, id, { | |
entry: `${__dirname}/check_stytch_authorizer.ts`, | |
architecture: Architecture.ARM_64, | |
environment:{ | |
} | |
}); |
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 {NodejsFunction} from "aws-cdk-lib/aws-lambda-nodejs"; | |
import {HttpMethod} from "aws-cdk-lib/aws-events"; | |
export interface ApiRestEndpoint { | |
description: string, | |
id: string, | |
fun: NodejsFunction, | |
https_methods: Array<HttpMethod>, | |
path: string | |
} |
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 {Client} from "stytch/types/lib/client"; | |
const stytch = require("stytch"); | |
const creds = require('../../_secrets/stytch_credentials_TEST.json'); | |
let client:Client; | |
export const loadStytch = ():Client => { | |
if(!client) { | |
client = new stytch.Client({ | |
project_id: creds.id, |