Code Monkey home page Code Monkey logo

quick-url-kata's Introduction

quick url

Url shortener "kata"

API usage:

Http method endpoint request body description response
POST /shorten { "url": "https://google.com" } generate a random slug 201 {"url": "https://google.com","slug": "opt-nk"}
POST /shorten { "url": "https://google.com", "slug": "gg" } use a user-provided slug 201 {"url": "https://google.com","slug": "gg"}
GET /{slug} - redirects to the given slug (if it exists) 302, redirecting to the url reigstered to {slug}

Running the project locally

The project uses maven for dependency management and building:

If you have Java installed locally:

  • ./mvnw clean install
  • java -jar target/*.java

NOTE: The project has a dependency to MongoDB. A local instance can be brought up with docker-compose using docker-compose up Otherwise, a remote one needs to be configured. Check out application.properties for the relevant configurations and keep in mind that a property like spring.data.mongodb.host can be overridden with the env var SPRING_DATA_MONGODB_HOST .

Running the project with docker

a maven docker image can be used directly:

  • docker run -it --rm -v "$PWD":/usr/src/quickurl -v "$HOME/.m2":/root/.m2 -w /usr/src/quickurl maven:3.3-jdk-8 mvn clean install
    • (-v "$HOME/.m2":/root/.m2 is optional, but allows for maven cache to be reused in subsequent runs, speeding up the build process a lot)

And then you can build an image and run the app using:

docker build -t test/quickurl . && \
docker run \
    --interactive \
    --tty \
    --rm \
    --network quickurl_network \
    --env SPRING_DATA_MONGODB_HOST=quickurl_mongo \
    -p 8080:8080 \
    --name test \
    test/quickurl \
    java -jar /opt/app/quickurl.jar

quick-url-kata's People

Contributors

viktorpenelski avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.