1.0.0 • Published 11 months ago

ant-simple-calculator v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
11 months ago

API SERVICE FOR CALCULATOR in Node.js,MongoDB and Typescript

This is API SERVICE FOR CALCULATOR in node.js project using typescript and mongodb. To connect with database we are using mongoose ODM.

Authors

Contact Details

  • Priyanka Ranjan
  • Email: priyanka.ranjan@antiersolutions.com

Tech Stack

  • TypeScript - TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
  • Express - Node Framweork.

  • Nodemon - Use for development file reload.

  • CORS - a node.js package for providing a Connect/Express middleware that can be used to enable CORS with various options.

  • Winston - A multi-transport async logging library for node.js.

  • mongoose - ODM library for mongoDB.

  • Helmet - Library to increase security of node server.

Logging

  • winston - a multi-transport async logging library for Node.js. It is designed to be a simple and universal logging library with support for multiple transports. A transport is essentially a storage device for your logs. Each instance of a winston logger can have multiple transports configured at different levels. For example, one may want error logs to be stored in a persistent remote location (like a database), but all logs output to the console or a local file.
  • morgan - HTTP request logger middleware for Node.js. A helper that collects logs from your server, such as your request logs.

Tests

  • mocha - Test Framweork for JavaScript.
  • chai - Assertion library for javascript.

Install

Install the package from NPM:

# If you use NPM
npm install ant-simple-calculator

Usage

The package provides a calculator class in which there are four function Add,Subtract,Multiply and Divide. You can import npm as follow.

import Calculator from "ant-simple-calculator";
const calculator = new Calculator();

You can call Add function so that you need to pass two number which you want to Add

const AddTwoNumber = async (num1, num2) => {
  const AddNumber = await calculator.Add(num1, num2);
  console.log("Add Two Number: ", AddNumber);
};
AddTwoNumber(2, 4);

You can call Subtract function so that you need to pass two number which you want to Subtract

const SubtractTwoNumber = async (num1, num2) => {
  const AddNumber = await calculator.Subtract(num1, num2);
  console.log("Subtract Number: ", AddNumber);
};
SubtractTwoNumber(10, 2);

You can call Multiply function so that you need to pass two number which you want to Multiply

const MultiplyTwoNumber = async (num1, num2) => {
  const AddNumber = await calculator.Multiply(num1, num2);
  console.log("Multiply Number: ", AddNumber);
};
MultiplyTwoNumber(3, 4);

You can call Divide function so that you need to pass two number which you want to Divide

const DivideTwoNumber = async (num1, num2) => {
  const AddNumber = await calculator.Divide(num1, num2);
  console.log("Divide Number: ", AddNumber);
};
DivideTwoNumber(10, 2);

Keywords

Calculator API Axios

THANK YOU

1.0.0

11 months ago