Skip to content

feat: webinar registration event forward to AC #345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: feature/v3/build-new-page-for-webinars
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,22 @@ import { loadEnv } from "vite";
import vue from "@astrojs/vue";
import tailwindcss from "@tailwindcss/vite";
import sitemap from "@astrojs/sitemap";
const env = loadEnv(process.env.NODE_ENV ?? 'development', process.cwd(), '');
const baseUrl = env.PUBLIC_APP_BASE_URL
import node from "@astrojs/node";

const env = loadEnv(process.env.NODE_ENV ?? "development", process.cwd(), "");
const baseUrl = env.PUBLIC_APP_BASE_URL;

// https://astro.build/config
export default defineConfig({
site: baseUrl, //change it with site url
adapter: node({
mode: "standalone",
}),
integrations: [vue(), sitemap()],
vite: {
plugins: [tailwindcss()],
},
prefetch: {
prefetch: {
prefetchAll: true,
defaultStrategy: "hover",
},
Expand Down
1,574 changes: 1,444 additions & 130 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@
"scripts": {
"dev": "astro dev",
"build": "astro build",
"build:aws": "npm run build && node scripts/build-lambda.js",
"deploy:aws": "npm run build:aws && serverless deploy",
"preview": "astro preview",
"astro": "astro"
},
"dependencies": {
"@astrojs/node": "^9.2.2",
"@astrojs/sitemap": "^3.3.1",
"@astrojs/vue": "^5.0.11",
"@tailwindcss/typography": "^0.5.16",
"astro": "^5.7.5",
"astro-sst": "^3.1.4",
"lucide-vue-next": "^0.503.0",
"marked": "^15.0.6",
"motion-v": "^1.1.1",
Expand All @@ -24,6 +28,8 @@
},
"devDependencies": {
"@tailwindcss/vite": "^4.1.4",
"serverless": "^4.17.1",
"serverless-s3-sync": "^3.4.0",
"tailwindcss": "^4.1.4"
}
}
63 changes: 63 additions & 0 deletions scripts/build-lambda.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import fs from "fs";
import path from "path";

// Create lambda directory
const lambdaDir = "dist/lambda";
if (!fs.existsSync(lambdaDir)) {
fs.mkdirSync(lambdaDir, { recursive: true });
}

// Lambda wrapper template
const createLambdaWrapper = (apiPath) => `
import { handler as astroHandler } from '../server/entry.mjs';

export const handler = async (event, context) => {
try {
// Convert AWS Lambda event to standard Request
const url = new URL(event.path, 'https://example.com');
if (event.queryStringParameters) {
Object.entries(event.queryStringParameters).forEach(([key, value]) => {
url.searchParams.set(key, value);
});
}

const request = new Request(url.toString(), {
method: event.httpMethod,
headers: event.headers,
body: event.body,
});

// Call Astro handler
const response = await astroHandler(request);

// Convert Response to AWS Lambda format
const body = await response.text();

return {
statusCode: response.status,
headers: Object.fromEntries(response.headers.entries()),
body: body,
};
} catch (error) {
console.error('Lambda error:', error);
return {
statusCode: 500,
body: JSON.stringify({ error: 'Internal Server Error' }),
};
}
};
`;

// Create Lambda functions for each API route
const apiRoutes = [
{ name: "webinar-register", path: "/api/webinar-register" },
{ name: "webinars-sync", path: "/api/webinars-sync" },
];

apiRoutes.forEach((route) => {
const lambdaCode = createLambdaWrapper(route.path);
fs.writeFileSync(path.join(lambdaDir, `${route.name}.js`), lambdaCode);
console.log(`✅ Created Lambda function: ${route.name}.js`);
});

console.log("🚀 Lambda functions built successfully!");
110 changes: 110 additions & 0 deletions serverless.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
service: openobserve-website

provider:
name: aws
runtime: nodejs18.x
region: us-east-2 # Change to your preferred region
stage: ${opt:stage, 'dev'}
environment:
ZOOM_CLIENT_ID: ${env:ZOOM_CLIENT_ID, ''}
ZOOM_CLIENT_SECRET: ${env:ZOOM_CLIENT_SECRET, ''}
ZOOM_ACCOUNT_ID: ${env:ZOOM_ACCOUNT_ID, ''}
STRAPI_TOKEN: ${env:STRAPI_TOKEN, ''}
PUBLIC_API_BASE_URL: ${env:PUBLIC_API_BASE_URL, ''}
iam:
role:
statements:
- Effect: Allow
Action:
- s3:GetObject
- s3:PutObject
- s3:ListBucket
Resource: "arn:aws:s3:::${self:custom.bucketName}/*"

functions:
webinarRegister:
handler: dist/lambda/webinar-register.handler
timeout: 30
memorySize: 256
events:
- httpApi:
path: /api/webinar-register
method: post
cors:
origin: "*"
headers:
- Content-Type
- Authorization
methods:
- POST
- OPTIONS

webinarsSync:
handler: dist/lambda/webinars-sync.handler
timeout: 30
memorySize: 256
events:
- httpApi:
path: /api/webinars-sync
method: get
cors:
origin: "*"
headers:
- Content-Type
- Authorization
methods:
- GET
- OPTIONS

resources:
Resources:
# S3 Bucket for static website
WebsiteBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: openobserve-website-${self:provider.stage}
WebsiteConfiguration:
IndexDocument: index.html
ErrorDocument: 404.html
PublicAccessBlockConfiguration:
BlockPublicAcls: false
BlockPublicPolicy: false
IgnorePublicAcls: false
RestrictPublicBuckets: false

# S3 Bucket Policy
WebsiteBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket:
Ref: WebsiteBucket
PolicyDocument:
Statement:
- Effect: Allow
Principal: "*"
Action: s3:GetObject
Resource: "${self:custom.bucketName}/*"

plugins:
- serverless-s3-sync

custom:
bucketName: openobserve-website-${self:provider.stage}
s3Sync:
- bucketName: ${self:custom.bucketName}
localDir: dist
deleteRemoved: true
exclude:
- lambda/**
- "*.map"

package:
patterns:
- "!node_modules/**"
- "!src/**"
- "!.git/**"
- "!.env*"
- "!*.md"
- "!package*.json"
- "dist/lambda/**"
- "dist/server/**"
Loading