A cross-origin API service that tracks likes using unique IDs.
<script src="https://jamesllllllllll--019894a514b47659ac14319f8b619533.web.val.run/script.js"></script>
<div data-likes-id="your-unique-id"> <button class="likes-button">ā¤ļø <span class="likes-count">0</span></button> </div>
š” Customize the emoji: Change ā¤ļø to any emoji you want: š š š ā šÆ š š š š
Record a like for a specific ID:
{ "id": "life-universe-everything" }
Returns:
{ "success": true, "id": "life-universe-everything", "likeCount": 42 }
Get like count for a specific ID:
GET /api/likes/post-123
Returns:
{ "id": "post-123", "likeCount": 42 }
Get total likes across all IDs (for fun)
// Get current likes for a post
fetch('https://jamesllllllllll--019894a514b47659ac14319f8b619533.web.val.run/api/likes/post-123')
.then(res => res.json())
.then(data => {
document.querySelector('.likes-count').textContent = data.likeCount;
});
// Record a like
fetch('https://jamesllllllllll--019894a514b47659ac14319f8b619533.web.val.run/api/like', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ id: 'post-123' })
})
.then(res => res.json())
.then(data => {
// Update the likes count
});
āāā backend/
ā āāā database.ts # SQLite database setup and queries
āāā frontend/
ā āāā index.html # Documentation & demo
āāā script.js # Embeddable likes widget script
āāā index.ts # Main HTTP handler using Hono
āāā README.md # This file