Skip to content

Commit 2d7ae65

Browse files
authored
Merge pull request #1 from HapticHash/main
Merge main
2 parents 6fa28c4 + 967975d commit 2d7ae65

15 files changed

Lines changed: 6664 additions & 0 deletions

.DS_Store

6 KB
Binary file not shown.

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## Compressly
2+
3+
Shrink your files, keep the magic. Premium compression for creators who care about quality.

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)