Skip to content

taiwuchen/url-shortener-api

Repository files navigation

URL Shortener API

A URL shortener built with TypeScript and Node.js. It uses a PostgreSQL database and focuses on the essential functionality of converting long URLs into shortened versions and redirecting users based on the generated short codes. This project also supports user authentication and provides admin-only analytics features.

Features

Project File Overview

Setup and Installation

  1. Install Dependencies:

    Run the following command in your terminal from the project root:

    npm install
  2. Configure Environment Variables:

    Modify a .env file (or create a new one) with the following content:

    DB_HOST=localhost
    DB_PORT=5432
    DB_NAME=url_shortener
    DB_USER=your_db_username
    DB_PASSWORD=your_db_password
    JWT_SECRET=your_super_secret_key_here
  3. Initialize the Database Schema:

    The schema is automatically initialized when the application starts via database.ts:

Running the Application

Start the application with:

npx ts-node src/app.ts

API Documentation

The API is fully documented using OpenAPI. Render openapi.yaml with a tool like Swagger UI or Redoc.

Running Tests

Execute the tests using:

npm test

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors