Code Monkey home page Code Monkey logo

word-counter's Introduction

Word-counter

This mini-project is an example of using Quarkus with Dependency Injection

  • We use Redis as a Dependency example

This API will allow you to upload a text file and fetch details of the uploaded documents

Quarkus https://quarkus.io/ Redis https://redis.io/

Local Standup

Create a redis container & run App:

docker run --ulimit memlock=-1:-1 -it --rm=true --memory-swappiness=0 --name redis_quarkus_test -p 6379:6379 redis:5.0.6
./mvnw clean compile quarkus:dev

Upload text

POST text to http://localhost:8080/files to add the text file to the data-store e.g.

curl -X POST --data 'Hello World' http://localhost:8080/files

This will return an id for that text file.

Read details of text document

set a GET request to http://localhost:8080/files/{fileId} e.g.

curl http://localhost:8080/files/c5d0805a-9535-45db-bda8-0ae09a8b8815

This will return details of word length etc formatted in the form:

Word count = 9
Average word length = 4.556
Number of words of length 1 is 1
Number of words of length 2 is 1
Number of words of length 3 is 1
Number of words of length 4 is 2
Number of words of length 5 is 2
Number of words of length 7 is 1
Number of words of length 10 is 1
The most frequently occurring word length is 2, for word lengths of 4 & 5

Running tests

  1. Create a redis container
    docker run --ulimit memlock=-1:-1 -it --rm=true --memory-swappiness=0 --name redis_quarkus_test -p 6379:6379 redis:5.0.6
  2. Run J-unit 5 tests as normal (src/main/jva/org.jaspinall.file/FileResourceTest.java)

word-counter's People

Contributors

lexxns 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.