Skip to content

Latest commit

 

History

47 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

URL-Shortening-Service

The project assignment for roadmap.sh

URL of the assignment in roadmap.sh:
https://roadmap.sh/projects/url-shortening-service

This API creates and manages short URLs using a Postgres database (ORM: Drizzle).
Each short URL consists of a short code and a key to authenticate the creator.
Using the key, creators can edit or delete their short URLs and can also see their stats.
The API has rate limiting to prevent abuse.

Read the docs here.

Installation

  1. Clone the repository:

    git clone https://github.com/ilia-abbasi/URL-Shortening-Service.git
    cd URL-Shortening-Service
  2. Install dependencies:

    npm install
  3. Create the .env file inside the /misc directory and set the variables:

    PORT=your_port
    DATABASE_URL=your_database_connection_string
    DATABASE_URL_TEST=your_test_database_connection_string

    You can ignore DATABASE_URL_TEST if you don't want to run tests.

  4. Create the required tables in your database:

    npm run generate # Generate migration files
    npm run migrate
  5. If you want to run tests too, create the required tables in your test database:

    npm run migrate:test

Usage

  1. Build the project:

    npm run build
  2. Run the server with:

    npm run start
  3. Send requests using Postman. Testing short URLs is better done with a browser.

Testing

Testing is done with jest.

  • Run all the tests with:

    npm run test
  • Run unit tests with:

    npm run test:units
  • Run e2e tests with:

    npm run test:e2e

Dependencies

  • dotenv
  • drizzle-orm
  • express
  • express-rate-limit
  • express-validator
  • morgan
  • pg

Dev dependencies

  • @types/dotenv
  • @types/express
  • @types/express-rate-limit
  • @types/express-validator
  • @types/jest
  • @types/morgan
  • @types/node
  • @types/pg
  • @types/supertest
  • drizzle-kit
  • jest
  • nodemon
  • supertest
  • ts-jest
  • tsx
  • typescript

The source code is formatted with Prettier.


URL-Shortening-Service is licensed under the GPL-3.0 license.

About

A RESTful API that creates and manages short URLs

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages