Coder Social home page Coder Social logo

calc-api's Introduction

calc-api

This is a simple Node.js API that can perform basic arithmetic operations (addition, subtraction, multiplication, and division) on two numbers passed as query parameters.

Getting Started These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

Node.js

Running the API

Start the API by running the following command: npm start The API will be running on http://localhost:8000

Usage

To use the calculator API, make a GET request to http://localhost:8000/calculator with the following query parameters:

operation: The type of operation to perform. Can be one of add, subtract, multiply, divide. num1: The first number. num2: The second number. For example, to add 5 and 3, make a GET request to http://localhost:8000/calculator?operation=add&num1=5&num2=3

The API will return a JSON object with a single key result that contains the result of the operation.

Error Handling

In case of invalid parameters or invalid operation, the API will return a JSON object with an error key and message.

Limitations

This is a very simple example and it doesn't have any validation or error handling in place, you should add it in a production level implementation.

Built With

Node.js - JavaScript runtime Express.js - Web framework for Node.js

Author

Alebiosu Gbolahan

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.