feat(www): Add logic to the homepage and Steam integration (#258)

## Description
<!-- Briefly describe the purpose and scope of your changes -->


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Upgraded API and authentication services with dynamic scaling,
enhanced load balancing, and real-time interaction endpoints.
- Introduced new commands to streamline local development and container
builds.
- Added new endpoints for retrieving Steam account information and
managing connections.
- Implemented a QR code authentication interface for Steam, enhancing
user login experiences.

- **Database Updates**
- Rolled out comprehensive schema migrations that improve data integrity
and indexing.
- Introduced new tables for managing Steam user credentials and machine
information.

- **UI Enhancements**
- Added refreshed animated assets and an improved QR code login flow for
a more engaging experience.
	- Introduced new styled components for displaying friends and games.

- **Maintenance**
- Completed extensive refactoring and configuration updates to optimize
performance and development workflows.
- Updated logging configurations and improved error handling mechanisms.
	- Streamlined resource definitions in the configuration files.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
Wanjohi
2025-04-13 14:30:45 +03:00
committed by GitHub
parent 8394bb4259
commit f408ec56cb
103 changed files with 12755 additions and 2053 deletions

View File

@@ -1,53 +1,50 @@
import { vpc } from "./vpc";
import { bus } from "./bus";
import { auth } from "./auth";
import { domain } from "./dns";
import { secret } from "./secret";
import { cluster } from "./cluster";
import { postgres } from "./postgres";
sst.Linkable.wrap(random.RandomString, (resource) => ({
properties: {
value: resource.result,
},
}));
export const urls = new sst.Linkable("Urls", {
properties: {
api: "https://api." + domain,
auth: "https://auth." + domain,
site: $dev ? "http://localhost:3000" : "https://" + domain,
},
});
export const apiFunction = new sst.aws.Function("ApiFn", {
vpc,
handler: "packages/functions/src/api/index.handler",
permissions: [
{
actions: ["iot:*"],
resources: ["*"],
},
],
export const api = new sst.aws.Service("Api", {
cpu: $app.stage === "production" ? "2 vCPU" : undefined,
memory: $app.stage === "production" ? "4 GB" : undefined,
cluster,
command: ["bun", "run", "./src/api/index.ts"],
link: [
bus,
urls,
auth,
postgres,
secret.PolarSecret,
],
timeout: "3 minutes",
streaming: !$dev,
url: true
})
export const api = new sst.aws.Router("Api", {
routes: {
"/*": apiFunction.url
image: {
dockerfile: "packages/functions/Containerfile",
},
domain: {
name: "api." + domain,
dns: sst.cloudflare.dns(),
environment: {
NO_COLOR: "1",
},
})
export const outputs = {
api: api.url,
};
loadBalancer: {
domain: "api." + domain,
rules: [
{
listen: "80/http",
forward: "3001/http",
},
{
listen: "443/https",
forward: "3001/http",
},
],
},
dev: {
command: "bun dev:api",
directory: "packages/functions",
url: "http://localhost:3001",
},
scaling:
$app.stage === "production"
? {
min: 2,
max: 10,
}
: undefined,
});

View File

@@ -1,46 +1,75 @@
import { vpc } from "./vpc";
import { bus } from "./bus";
import { domain } from "./dns";
// import { email } from "./email";
import { secret } from "./secret";
import { postgres } from "./postgres";
import { cluster } from "./cluster";
import { vpc } from "./vpc";
export const authFingerprintKey = new random.RandomString(
"AuthFingerprintKey",
{
length: 32,
// sst.Linkable.wrap(random.RandomString, (resource) => ({
// properties: {
// value: resource.result,
// },
// }));
// export const authFingerprintKey = new random.RandomString(
// "AuthFingerprintKey",
// {
// length: 32,
// },
// );
export const auth = new sst.aws.Service("Auth", {
cpu: $app.stage === "production" ? "1 vCPU" : undefined,
memory: $app.stage === "production" ? "2 GB" : undefined,
cluster,
command: ["bun", "run", "./src/auth.ts"],
link: [
bus,
postgres,
secret.PolarSecret,
secret.GithubClientID,
secret.DiscordClientID,
secret.GithubClientSecret,
secret.DiscordClientSecret,
],
image: {
dockerfile: "packages/functions/Containerfile",
},
);
export const auth = new sst.aws.Auth("Auth", {
issuer: {
vpc,
timeout: "3 minutes",
handler: "packages/functions/src/auth.handler",
link: [
bus,
// email,
postgres,
authFingerprintKey,
secret.PolarSecret,
secret.GithubClientID,
secret.DiscordClientID,
secret.GithubClientSecret,
secret.DiscordClientSecret,
],
permissions: [
environment: {
NO_COLOR: "1",
STORAGE: $dev ? "/tmp/persist.json" : "/mnt/efs/persist.json"
},
//TODO: Use API gateway instead, because of the API headers
loadBalancer: {
domain: "auth." + domain,
rules: [
{
actions: ["ses:SendEmail"],
resources: ["*"],
listen: "80/http",
forward: "3002/http",
},
{
listen: "443/https",
forward: "3002/http",
},
],
},
domain: {
name: "auth." + domain,
dns: sst.cloudflare.dns(),
permissions: [
{
actions: ["ses:SendEmail"],
resources: ["*"],
},
],
dev: {
command: "bun dev:auth",
directory: "packages/functions",
url: "http://localhost:3002",
},
})
export const outputs = {
auth: auth.url,
};
scaling:
$app.stage === "production"
? {
min: 2,
max: 10,
}
: undefined,
});

View File

@@ -43,7 +43,7 @@ export const postgres = new sst.aws.Aurora("Database", {
new sst.x.DevCommand("Studio", {
link: [postgres],
dev: {
command: "bun db studio",
command: "bun db:dev studio",
directory: "packages/core",
autostart: true,
},

View File

@@ -1,9 +1,9 @@
import { urls } from "./api";
import { auth } from "./auth";
import { postgres } from "./postgres";
export const device = new sst.aws.Realtime("Realtime", {
authorizer: {
link: [urls, postgres],
handler: "./packages/functions/src/realtime/authorizer.handler"
link: [auth, postgres],
handler: "packages/functions/src/realtime/authorizer.handler"
}
})

View File

@@ -1,43 +1,7 @@
import { domain } from "./dns";
import { cluster } from "./cluster";
import { auth } from "./auth";
export const steam = new sst.aws.Service("Steam", {
cluster,
wait: true,
image: {
context: "packages/steam",
},
loadBalancer: {
domain:
$app.stage === "production"
? undefined
: {
name: "steam." + domain,
dns: sst.cloudflare.dns(),
},
rules: [
{ listen: "443/https", forward: "5289/http" },
{ listen: "80/http", forward: "5289/http" },
],
},
environment: {
NESTRI_AUTH_JWKS_URL: $interpolate`${auth.url}`
},
scaling:
$app.stage === "production"
? {
min: 2,
max: 4,
}
: undefined,
logging: {
retention: "1 month",
},
architecture: "arm64",
new sst.x.DevCommand("Steam", {
dev: {
command: "bun dev",
directory: "packages/steam",
command: "dotnet run",
url: "http://localhost:5289",
autostart: true,
},
})
});

View File

@@ -3,7 +3,6 @@ import { api } from "./api";
import { auth } from "./auth";
import { zero } from "./zero";
import { domain } from "./dns";
import { steam } from "./steam";
new sst.aws.StaticSite("Web", {
path: "packages/www",
@@ -20,6 +19,5 @@ new sst.aws.StaticSite("Web", {
VITE_STAGE: $app.stage,
VITE_AUTH_URL: auth.url,
VITE_ZERO_URL: zero.url,
VITE_STEAM_URL: steam.url,
},
})