Skip to content

Instantly share code, notes, and snippets.

View proton0210's full-sized avatar
🛠️
Making Serverless Applications on AWS

Vidit Shah proton0210

🛠️
Making Serverless Applications on AWS
View GitHub Profile
@proton0210
proton0210 / stepffunc environmentvariables
Created June 27, 2024 05:43
StepFunctions Environment Variables
NEXT_PUBLIC_APIGATEWAY_ENDPOINT=
NEXT_PUBLIC_REGION=
NEXT_PUBLIC_USER_POOL_ID=
NEXT_PUBLIC_USER_POOL_CLIENT_ID=
NEXT_PUBLIC_AWS_ID=
NEXT_PUBLIC_AWS_SECRET=
NEXT_PUBLIC_PRODUCT_TABLE=
NEXT_PUBLIC_BUCKET=
@proton0210
proton0210 / Sf Proxy function
Created June 15, 2024 14:00
12. proxy Function
// StepFunctionsProxy/handler.ts
import { StartExecutionCommand, SFNClient } from "@aws-sdk/client-sfn";
const stepFunctions = new SFNClient({});
export const handler = async (event: any) => {
console.log(JSON.stringify(event, null, 2));
const orderString = JSON.parse(event.body);
console.log({ orderString });
@proton0210
proton0210 / Sf Create Order
Created June 15, 2024 13:58
11-CreatOrder
// handler.ts
import { DynamoDBClient, PutItemCommand } from "@aws-sdk/client-dynamodb";
import { ulid } from "ulid";
const client = new DynamoDBClient({});
export const handler = async ({
order,
}: {
// handler.ts
import { DynamoDBClient, UpdateItemCommand } from "@aws-sdk/client-dynamodb";
const client = new DynamoDBClient({});
export const handler = async ({
item: { itemId, quantity },
}: {
item: { itemId: string; quantity: number };
}): Promise<void> => {
@proton0210
proton0210 / handler.ts
Created June 14, 2024 13:45
sf-UploadFile
import { DynamoDBClient, PutItemCommand } from "@aws-sdk/client-dynamodb";
import { PutObjectCommand, S3Client } from "@aws-sdk/client-s3";
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
import { ulid } from "ulid";
const dynamoDBClient = new DynamoDBClient({});
const s3Client = new S3Client({});
export const handler = async (event: {
body: string;
@proton0210
proton0210 / handler.ts
Last active June 14, 2024 13:10
4-sf-PostConfirmation
// npm i @aws-sdk/client-dynamodb @aws-sdk/util-dynamodb
// npm i -D @types/aws-lambda esbuild
import { DynamoDBClient, PutItemCommand } from "@aws-sdk/client-dynamodb";
import { PostConfirmationConfirmSignUpTriggerEvent } from "aws-lambda";
import { marshall } from "@aws-sdk/util-dynamodb";
const client = new DynamoDBClient();
exports.handler = async function (
import Link from "next/link";
import React from "react";
const Credits = ({ credits }: { credits: number }) => {
return (
<div className="absolute top-20 font-sans ">
Number of credits Available:
{" "}
{credits}
<div>
@proton0210
proton0210 / Testting URL
Created April 11, 2024 11:29
Stripe Check out
https://docs.stripe.com/testing#international-cards
@proton0210
proton0210 / Pricing.tsx
Last active April 11, 2024 17:24
Get Products
"use client";
import React from "react";
import { useEffect, useState } from "react";
import axios from "axios";
import { Price } from "@/types";
import { Button } from "./ui/button";
import Link from "next/link";
export default function Pricing({ clerkId }: { clerkId: string }) {
@proton0210
proton0210 / .env.local
Created April 11, 2024 10:35
Webhooks and Actions
NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL=/product
NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL=/product
NEXT_CLERK_WEBHOOK_SECRET=
AWS_REGION=
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_S3_BUCKET_NAME=
STRIPE_SECRET_KEY=x
STRIPE_WEBHOOK_SECRET=x