About | Features | Technologies | Requirements | Starting | License | Author
This is a calculator API made with Node.js and Express.js. It allows you to calculate an expression with the following operators: +, -, *, / and return the result. It contains a POST [/api/calculate] method that receives the expression to be calculated.
✔️ Calculate an expression with the following operators: +, -, *, / and return the result.
The following tools were used in this project:
Before starting 🏁, you need to have Git and Node installed.
# Clone this project
$ git clone https://github.com/ignaciocamargo99/calculatorAPI.git
# Install dependencies
$ npm install
# Run the project
$ npm start
# The server will initialize in the <http://localhost:3000>
URL:
POST /api/calculate
Content-Type:
application/json
POST method expects a JSON in the body of the request with the following structure:
{
"expression": "10 * (2 + 5) * 10"
}
Successfull Response (200):
{
"result": 700
}
Error Response (400):
{
"error": "Invalid or missing 'expression'"
}
- The mathematical expression should be valid and contain only supported operators (
+
,-
,*
,/
,()
). - Ensure that the server is running before making requests.
Made by Ignacio Camargo