Skip to content

Timothy-Rhodes/prime-number-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Prime Number API

Table of Contents


Overview

This is a simple JSON API that checks if a given number is prime.

Features:

  • Accepts an integer query parameter.
  • Returns true or false based on primality.
  • Handles invalid input gracefully.
  • Fully tested with Jest + Supertest.
  • Includes Swagger-based API documentation.

Installation & Setup

  1. Clone this repository:

    git clone https://github.com/Timothy-Rhodes/prime-number-api.git
    cd prime-number-api
    
  2. Install dependencies:

    npm install
  3. Start the server:

    node server.js
  4. The server will run on http://localhost:3000 by default.


API Usage

To check if a number is prime, make a GET request to the /is_prime endpoint with the number as a query parameter:

curl "http://localhost:3000/is_prime?number=19"

returns this JSON response:

{
  "number": "19",
  "is_prime": true
}

API Documentation

To view the API documentation, navigate to http://localhost:3000/docs in your browser.


Testing

To run the tests:

npm test

Tech Stack

  • Node.js
  • Express
  • Jest
  • Supertest
  • Swagger

About

Prime Number API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published