A simple word list service control plane.
It has the following capabilities:
- Check if a word exists in the word list
- Add a new word to the word list
- Find a list of words that match a given prefix
The word list is stored in a flat file at words.txt.
This endpoint checks if a word exists in the word list. This endpoint has some issues with it's implementation.
Expected functionality:
- It returns a 200 upon success
- It returns other status codes as appropriate (4XXs for input errors, 5XXs for internal server errors)
- The response body is a JSON object with a single field
existsof type boolean- Example:
{ "exists": true }
- Example:
- It performs case insensitive matching to the words in the wordlist
- It only returns true if the word exists (exactly matches)in the wordlist
This endpoint adds a new word to the word list. This endpoint needs to be implemented still.
Expected functionality:
- It returns a 204 upon success.
- It returns a 409 if the word already exists in the word list.
- It returns other status codes as appropriate (4XXs for input errors, 5XXs for internal server errors)
- The newly added word should persist for the life of the running Docker container.
- A word is considered a single string of unbroken alpha characters (no numbers or special characters)
This endpoint returns a list of words that match a given prefix. This endpoint needs to be more performant.
Expected functionality:
- It returns a 200 upon success
- It returns other status codes as appropriate (4XXs for input errors, 5XXs for internal server errors)
- The response body is a JSON object with a single field
matchesof type string array- Example:
{ "matches": ["word1", "word2"] }
- Example:
- It performs case insensitive matching to the words in the wordlist
- It only returns words that match the given prefix
All of the Go-related code is in the go directory.
From the root of this repo run:
docker build -f go/Dockerfile -t diccionario .
docker run -it -p 8080:8080 -v ./go:/usr/src/diccionario diccionarioThe server will be available at http://localhost:8080. It will automatically reload when you make changes to the source code (it's using air).
To stop the server, press Ctrl+C in the terminal where it's running.
To access the running container, run:
docker exec -it `docker ps | grep diccionario | awk '{print $1}'` bashTo exit the terminal session, press Ctrl+D in the terminal where it's running.
All of the Typescript-related code is in the ts directory.
From the root of this repo run:
docker build -f ts/Dockerfile -t diccionario .
docker run -it -p 5000:5000 -v ./ts:/usr/src/diccionario -v /usr/src/diccionario/node_modules diccionarioThe server will be available at http://localhost:5000. It will automatically reload when you make changes to the source code.
To stop the server, press Ctrl+C in the terminal where it's running.
To access the running container, run:
docker exec -it `docker ps | grep diccionario | awk '{print $1}'` bashTo exit the terminal session, press Ctrl+D in the terminal where it's running.
--- TODO
- Noted some bugs in the exist endpoint, figure those out and fixc
- matches endpoint is slow
- turns out humans create new words all the time, so /add would be coolio