Skip to content

Commit 9b7a268

Browse files
committed
initial commit
1 parent 6fa28c4 commit 9b7a268

15 files changed

Lines changed: 6681 additions & 0 deletions

.DS_Store

6 KB
Binary file not shown.

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<div align="center">
2+
<img width="1200" height="475" alt="GHBanner" src="https://github.com/user-attachments/assets/0aa67016-6eaf-458a-adb2-6e31a0763ed6" />
3+
</div>
4+
5+
# Run and deploy your AI Studio app
6+
7+
This contains everything you need to run your app locally.
8+
9+
View your app in AI Studio: https://ai.studio/apps/7af33c3c-5f27-4af8-b633-d606afc78ee1
10+
11+
## Run Locally
12+
13+
**Prerequisites:** Node.js
14+
15+
16+
1. Install dependencies:
17+
`npm install`
18+
2. Set the `GEMINI_API_KEY` in [.env.local](.env.local) to your Gemini API key
19+
3. Run the app:
20+
`npm run dev`

functions/api/health.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export async function onRequest(context: any) {
2+
return new Response(JSON.stringify({ status: 'ok' }), {
3+
headers: {
4+
'Content-Type': 'application/json',
5+
'Access-Control-Allow-Origin': '*',
6+
},
7+
});
8+
}

functions/api/stats.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
export async function onRequestGet(context: any) {
2+
try {
3+
const { env } = context;
4+
// COMPRESSLY_STATS is the KV namespace binding
5+
let totalFilesCompressed = await env.COMPRESSLY_STATS.get('totalFilesCompressed');
6+
let totalDataSaved = await env.COMPRESSLY_STATS.get('totalDataSaved');
7+
8+
return new Response(JSON.stringify({
9+
totalFilesCompressed: parseInt(totalFilesCompressed || '0', 10),
10+
totalDataSaved: parseInt(totalDataSaved || '0', 10)
11+
}), {
12+
headers: {
13+
'Content-Type': 'application/json',
14+
'Access-Control-Allow-Origin': '*',
15+
},
16+
});
17+
} catch (err) {
18+
return new Response(JSON.stringify({ error: err.message }), { status: 500 });
19+
}
20+
}
21+
22+
export async function onRequestPost(context: any) {
23+
try {
24+
const { request, env } = context;
25+
const body = await request.json();
26+
const { filesCount = 0, bytesSaved = 0 } = body;
27+
28+
let currentFiles = parseInt(await env.COMPRESSLY_STATS.get('totalFilesCompressed') || '0', 10);
29+
let currentSaved = parseInt(await env.COMPRESSLY_STATS.get('totalDataSaved') || '0', 10);
30+
31+
const newFiles = currentFiles + filesCount;
32+
const newSaved = currentSaved + bytesSaved;
33+
34+
await env.COMPRESSLY_STATS.put('totalFilesCompressed', newFiles.toString());
35+
await env.COMPRESSLY_STATS.put('totalDataSaved', newSaved.toString());
36+
37+
return new Response(JSON.stringify({ success: true }), {
38+
headers: {
39+
'Content-Type': 'application/json',
40+
'Access-Control-Allow-Origin': '*',
41+
},
42+
});
43+
} catch (err) {
44+
return new Response(JSON.stringify({ error: err.message }), { status: 500 });
45+
}
46+
}
47+
48+
export async function onRequestOptions() {
49+
return new Response(null, {
50+
headers: {
51+
'Access-Control-Allow-Origin': '*',
52+
'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
53+
'Access-Control-Allow-Headers': 'Content-Type',
54+
},
55+
});
56+
}

gitignore.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
node_modules/
2+
build/
3+
dist/
4+
coverage/
5+
.DS_Store
6+
*.log
7+
.env*
8+
!.env.example

index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>My Google AI Studio App</title>
7+
</head>
8+
<body>
9+
<div id="root"></div>
10+
<script type="module" src="/src/main.tsx"></script>
11+
</body>
12+
</html>
13+

metadata.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "Compressly",
3+
"description": "Shrink your files, keep the magic. Premium compression for creators who care about quality.",
4+
"requestFramePermissions": []
5+
}

0 commit comments

Comments
 (0)