Skip to content
Merged
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
Binary file added .DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Compressly

Shrink your files, keep the magic. Premium compression for creators who care about quality.
8 changes: 8 additions & 0 deletions functions/api/health.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export async function onRequest(context: any) {
return new Response(JSON.stringify({ status: 'ok' }), {
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*',
},
});
}
56 changes: 56 additions & 0 deletions functions/api/stats.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
export async function onRequestGet(context: any) {
try {
const { env } = context;
// COMPRESSLY_STATS is the KV namespace binding
let totalFilesCompressed = await env.COMPRESSLY_STATS.get('totalFilesCompressed');
let totalDataSaved = await env.COMPRESSLY_STATS.get('totalDataSaved');

return new Response(JSON.stringify({
totalFilesCompressed: parseInt(totalFilesCompressed || '0', 10),
totalDataSaved: parseInt(totalDataSaved || '0', 10)
}), {
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*',
},
});
} catch (err) {
return new Response(JSON.stringify({ error: err.message }), { status: 500 });
}
}

export async function onRequestPost(context: any) {
try {
const { request, env } = context;
const body = await request.json();
const { filesCount = 0, bytesSaved = 0 } = body;

let currentFiles = parseInt(await env.COMPRESSLY_STATS.get('totalFilesCompressed') || '0', 10);
let currentSaved = parseInt(await env.COMPRESSLY_STATS.get('totalDataSaved') || '0', 10);

const newFiles = currentFiles + filesCount;
const newSaved = currentSaved + bytesSaved;

await env.COMPRESSLY_STATS.put('totalFilesCompressed', newFiles.toString());
await env.COMPRESSLY_STATS.put('totalDataSaved', newSaved.toString());

return new Response(JSON.stringify({ success: true }), {
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*',
},
});
} catch (err) {
return new Response(JSON.stringify({ error: err.message }), { status: 500 });
}
}

export async function onRequestOptions() {
return new Response(null, {
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
'Access-Control-Allow-Headers': 'Content-Type',
},
});
}
8 changes: 8 additions & 0 deletions gitignore.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules/
build/
dist/
coverage/
.DS_Store
*.log
.env*
!.env.example
13 changes: 13 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>My Google AI Studio App</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>

5 changes: 5 additions & 0 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Compressly",
"description": "Shrink your files, keep the magic. Premium compression for creators who care about quality.",
"requestFramePermissions": []
}
Loading