A simple server built with NestJS that tracks the frequency of input keys submitted via HTTP requests.
POST /input
- Description: Increments the count of the key if the key already exists, otherwise creates a new key with a count of 1. The key is case-sensitive and is trimmed before being stored.
- Request Headers:
Content-Type: text/plain
. Otherwise, the server will respond with a 415 Unsupported Media Type error. - Request Body: Non-empty string containing the key to be stored. Throws a 400 Bad Request error if the body is empty.
- Success Response:
204 No Content
GET /query
- Description: Retrieves the count of the key. The key is case-sensitive and is trimmed before being queried.
- Query Parameters:
key
- Non-empty string containing the key to be queried. Throws a 400 Bad Request error if the key is not provided. - Success Response:
200 OK
with the count of the key in the response body.
-
Clone the repository:
git clone [email protected]:toramanomer/key-counter.git
-
Navigate to the project directory, and install the dependencies:
cd key-counter && npm install
-
Start the server in watch mode:
npm run start:dev
After installing the dependencies, you can build the project with the following command:
npm run build && npm run start:prod
- Build Script is provided to build the Docker image.
chmod +x scripts/build.sh && scripts/build.sh
- Run Script is provided to run the Docker container.
chmod +x scripts/run.sh && scripts/run.sh
npm run test:e2e
- Prettier - Code formatter
- ESLint
- Docker if you want to run the server in a container
- REST Client for testing endpoints using the provided requests file