This task is to implement an API endpoint, deploying it and providing an URL for testing. You can follow the quick start guide to start building the API. You should implement an endpoint to analyze text. Curl command to call your API might look like this:
curl --header "Content-Type: application/json" \
--request POST \
--data '{"text":"hello 2 times "}' \
https://mysuperawesomeapi.com/analyze
And the response should be:
{
"textLength":{"withSpaces":15,"withoutSpaces":11},
"wordCount":3,
"characterCount":[{"e":2},{"h":1},{"i":1},{"l":2},{"m":1},{"o":1},{"s":1},{"t":1}]
}
- Nodejs
Open-source and cross-platform JavaScript runtime environment
- Express
Fast, unopinionated, minimalist web framework for Node.js
- Javascript
prototype-based, multi-paradigm, dynamic language, supporting object-oriented, imperative, and declarative (e.g. functional programming) styles
- Jest
a delightful JavaScript Testing Framework with a focus on simplicity.
- Travis-CI
continuous integration platform that supports our development process by automatically building and testing code changes, providing immediate feedback on the success of the change
- Standard JS
JavaScript style guide, linter, and formatter which automatically format code, catch style issues & programmer errors early and need no configuration
- Open up your favorite kind of console
- Navigate to the folder in which you want to store the source code
- Run
git clone https://github.com/ranabhat/db-programming-assignment.git
- Open up the source code in your code editor (I recommend Visual Studio Code if you don't have a preference)
- Run
npm install
in the console to install dependencies (it'll take a while on the first run, so go on and read ahead while you wait) - Start modifying the code to build your own application
- Run
npm run start
in console - Open your browser in the address printed to the console
- From Terminal
curl --header "Content-Type: application/json" \ --request POST \ --data '{"text":"hello 2 times "}' \ https://localhost:8080/analyze
- Go to the directory that has Dockerfile and run
docker build -t <nameyouwanttogive> .
- Run the image
docker run -p 49160:8080 -d <nameyouwanttogive>
- Run
curl -i localhost:49160/analyze
- Run
curl -i --header "Content-Type: application/json" \ --request POST \ --data '{"text":"hello 2 times "}' \ localhost:49160/analyze
- Run
curl -i --header "Content-Type: application/json" \ --request POST \ --data '{"text":"hello 2 times "}' \ https://db-challenge-db.herokuapp.com/analyze
All of the code is licensed under the MIT license