Skip to content
This repository was archived by the owner on Jun 10, 2024. It is now read-only.

DarkendHall/url_shortener

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

98 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

URL Shortener

This repository contains code to shorten URLs, it is a part of the final examination of the course "Webservices".
There are currently four branches which contain three different versions of the application.

  • The main branch contains a Micronaut version(Native Image + Consul Service Discovery + Consul Config)
  • The quarkus branch contains a Quarkus version(Native image), development of this version has stopped.
  • The spring-boot branch contains a Spring Boot version, development of this version has stopped.
  • The micronaut branch is no longer active. Development of this version has moved to the main branch, but this branch is kept for documentation

Example JSON body

{
  "url": "http://google.com"
}

The link needs to have http:// or https:// in the beginning, www is optional


Micronaut Specifics

Environment Variables

Environment variable Description Default
CONSUL_HOST The URL/IP address of the Consul server localhost
CONSUL_PORT The port of the Consul server 8500

Example Configuration:

Should be placed in k/v store in config/url-shortener and in yaml format.
The reason why it's not url_shortener is because consul doesn't appear to support "_" in the name of services.

micronaut:
  server:
    port: 8080
datasources:
  default:
    url: jdbc:mysql://<database_url>
    username: <username> # This is stored as clear text, will probably not be updated to be stored as a secret at this time.
    password: <password> # This is stored as clear text, will probably not be updated to be stored as a secret at this time.
    dialect: MYSQL
jpa.default.properties.hibernate.hbm2ddl.auto: update
netty:
  default:
    allocator:
      max-order: 3

To package to native image and create a Docker image run the following command if you HAVE Maven installed on your machine:
mvn -B package -Dpackaging=docker-native -Pgraalvm --file pom.xml

To package to native image and create a Docker image run the following command if you DO NOT HAVE Maven installed on your machine:
./mvnw -B package -Dpackaging=docker-native -Pgraalvm --file pom.xml

Run command:

docker run --name url_shortener -d -p 8080:8080 -e CONSUL_HOST=localhost -e CONSUL_PORT=8500 ghcr.io/darkendhall/url_shortener:micronaut

About

This repository contains code for a service that will allow you to shorten an URL. It is also a part of the final examination for the course "Webservices".

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors