url-shortener

command module
v0.0.0-...-c44b3c4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2024 License: GPL-3.0 Imports: 2 Imported by: 0

README

URL Shortener

Simple and minimalism URL Shortener

Made out of

  • Golang for backend
  • XORM as ORM
  • Echo as HTTP Framework
  • go-playground/validator as Validator
  • Cobra as cli and configuration manager
  • TS for frontend
  • Vue3 as Frontend framework
  • Ant Design Vue as UI Components
  • ...

Screenshots

Running project

just run project with --help to see options and their env equivalent

Configuration params
  • FLAG: --add-referer-query-param
    ENV: USH_ADD_REFERER_QUERY_PARAM
    Default: true
    Description: Add referer query param to redirect url or not

  • FLAG: --database-connection-string
    ENV: USH_DATABASE_CONNECTION_STRING
    Default: "./database.sqlite3"
    Description: Connection string of database, use postgres://127.0.0.1:5432/url_shortener for postgres and root:@tcp(127.0.0.1:3306)/url_shortener?charset=utf8 for mysql

  • FLAG: --database-engine
    ENV: USH_DATABASE_ENGINE
    Default: "sqlite"
    Description: The engine of database, use pgx for postgres, mysql for mysql and sqlite for sqlite

  • FLAG: --database-max-connection-lifetime
    ENV: USH_DATABASE_MAX_CONNECTION_LIFETIME
    Default: "5m0s"
    Description: Maximum lifetime for database connections in second used by connection pool

  • FLAG: --database-max-idle-connections
    ENV: USH_DATABASE_MAX_IDLE_CONNECTIONS
    Default: 4
    Description: Number of maximum idle connections to database used by connection pool

  • FLAG: --database-max-open-connections
    ENV: USH_DATABASE_MAX_OPEN_CONNECTIONS
    Default: 10
    Description: Number of maximum open connections to database used by connection pool

  • FLAG: --jwt-secret
    ENV: USH_JWT_SECRET
    Default: "superdupersecret"
    Description: jwt secret to sign tokens with, strongly recommended to change

  • FLAG: --listen-address/-l
    ENV: USH_LISTEN_ADDRESS
    Default: "127.0.0.1:8080"
    Description: Host:Port to listen

  • FLAG: --migrate/-m
    ENV: USH_MIGRATE
    Default: true
    Description: To run migrations or not

  • FLAG: --random-generator-max
    ENV: USH_RANDOM_GENERATOR_MAX
    Default: 10000
    Description: Generator will use this to generate shortcodes (higher value = bigger shortcodes), at least 10000 should be set

  • FLAG: --root-redirect/-r
    ENV: USH_ROOT_REDIRECT
    Default: "/ui/"
    Description: Path/URL to redirect when someone comes to root url

  • FLAG: --run-server/-s
    ENV: USH_RUN_SERVER
    Default: true
    Description: To run webserver or not

Running Locally (for development)

Unix Users Only use run script, it will install dependencies, format the code and run the project

Docker (for production)

Available as ghcr.io/mhkarimi1383/url-shortener:main

sample docker-compose in available as docker-compose.yaml

simply run that with the options/envs as you want

TODO

  • Add more deploy/build options
  • API Documentation (swaggo is buggy and generating errors with some datatypes)
  • Vue3 Frontend
  • Webhook and Reporting Support

Documentation

Overview

Copyright © 2023 Muhammed Hussein Karimi info@karimi.dev

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL