Thanks to visit codestin.com
Credit goes to github.com

Skip to content

sudo-self/links

Repository files navigation

create calendar events of any type

serverless postgreSQL intigration

shapes at 25-12-13 00 15 14

Likes API

A lightweight API for tracking page likes with user deduplication, built with TypeScript, Express.js, and PostgreSQL.

Features

  • ✅ Track page likes with user-based deduplication

  • ✅ Real-time like count updates

  • ✅ RESTful API endpoints

  • ✅ PostgreSQL with connection pooling

  • ✅ Automatic database schema initialization

  • ✅ Row-level security policies (if enabled)

  • ✅ Efficient indexing for performance

Tech Stack

  • Runtime: Node.js

  • Framework: Express.js

  • Language: TypeScript

  • Database: PostgreSQL (hosted on Neon)

  • ORM: pg (PostgreSQL client for Node.js)

  • Authentication: JWT (via Supabase Auth)

Prerequisites

  • Node.js 18+

  • PostgreSQL database (Neon recommended)

  • npm or yarn package manager

Installation

  1. Clone the repository
git clone https://github.com/sudo-self/links.git && cd links
 
  1. Install
npm install

  1. env example

DATABASE_URL=postgresql://username:[email protected]/dbname

PORT=3000

NODE_ENV=development

  1. Database Schema:
  • page_stats table
CREATE TABLE page_stats (

page_id VARCHAR(255) PRIMARY KEY,

like_count INTEGER DEFAULT 0,

created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,

updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP

);
  • page_likes table

CREATE TABLE page_likes (

id BIGSERIAL PRIMARY KEY,

page_id VARCHAR(255) NOT NULL,

user_hash VARCHAR(255) NOT NULL,

created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,

UNIQUE(page_id, user_hash),

FOREIGN KEY (page_id) REFERENCES page_stats(page_id) ON DELETE CASCADE

);

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published