Skip to content

This project is a simple service that allows users to get shorter versions of urls.

Notifications You must be signed in to change notification settings

Seerendo/url_shortener

Repository files navigation

Introduction

This project is a simple service that allows users to get shorter versions of urls.

Libraries

  • Programming language: Typescript
  • Environment: Node
  • Server framework: Express
  • Database: PostgreSQL
  • ORM: TypeORM
  • Test: Vitest
  • Lint: Eslint
  • Code formatter: Prettier
  • Logger: Winston

Configuration files

  • .eslintrc: Eslint configuration file
  • .prettierrc: Prettier Formatt configuration file
  • vitest.config.ts: Vitest configuration file

Project structure

  • src/app/: ORM config and Express Server entry point
  • src/url/: Url
    • delivery/: Express routes and middlewares
    • domain/: Domain of the entity, repository and usecase interfaces
    • repository/: ORM Schema and requests
    • usecase/: Business rules
  • test/: Tests

Run with npm

  • Create .env file from .env.example, filling in the missing details
  • Install dependencies: npm install
  • Build server: npm run build
  • Start server: npm run start

Run with docker-compose

  • Create and run containers: docker-compose up --build
  • Verify docker containers logs: docker-compose logs -f
  • Stop and remove containers: docker-compose down

API

  1. Shorten an URL POST /api/url

Request body

{
    originalUrl: string,
    alias: string?
}

Response

{
  "message": string
  "shortUrl": string | null
}
  1. Redirect shortened URL GET /api/url/:urlCode

Clean Architecture

Source: https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html

About

This project is a simple service that allows users to get shorter versions of urls.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published