Skip to content

This is a repository for a challenge of a calculator API

Notifications You must be signed in to change notification settings

ignaciocamargo99/calculatorAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Calculator API

About   |   Features   |   Technologies   |   Requirements   |   Starting   |   License   |   Author


🎯 About

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.

✨ Features

✔️ Calculate an expression with the following operators: +, -, *, / and return the result.

🚀 Technologies

The following tools were used in this project:

✅ Requirements

Before starting 🏁, you need to have Git and Node installed.

🏁 Starting

# 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>

🌐 Endpoint

URL:
POST /api/calculate

Content-Type:
application/json


📥 Request Parameters

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'"
}

📝 Notes

  • The mathematical expression should be valid and contain only supported operators (+, -, *, /, ()).
  • Ensure that the server is running before making requests.

📝 License

Made by Ignacio Camargo

 

Back to top

About

This is a repository for a challenge of a calculator API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published