npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gameart-task-kilian

v1.12.0

Published

This is a simple RESTful API built with Express.js that responds with "pong" when a GET request is made to the "/ping" endpoint.

Downloads

15

Readme

Simple Ping-Pong API

This is a simple RESTful API built with Express.js that responds with "pong" when a GET request is made to the "/ping" endpoint.

Usage

  1. Start by installing (if not already) this package with npm i gameart-task-kilian.
  2. Start the server by running npm run pingpongserver.
  3. Access the server at http://localhost:3000/ping in your browser or any API client.

Customization

You can customize the API response by adding a query parameter called "username" to the request URL. The API will include the provided username in the response.

For example, to set the username as "Kilian", you can access the server at http://localhost:3000/ping?username=Kilian.

If no username is provided, a default value of "GameArt back-end developer" will be used.

Testing

The API includes tests to ensure its functionality. To run the tests, use the following command:

npm test

Make sure you have installed "jest" & "supertest" before, otherwise do it with the following commands :

npm i jest
npm i supertest

Error Handling

The API includes basic error handling to handle internal server errors. If any error occurs during the processing of a request, an appropriate error response will be sent.

Internal Server Error

If an internal server error occurs, the API will respond with a status code of 500 and the message "Internal Server Error".

JavaScript Functions

This code demonstrates various JavaScript functions that make use of map, filter, and reduce to manipulate an array of integers. The array used in the examples is [24, 56, 1, 25, 67, 24, 89, 21, 53, 24, 56].

Usage

  1. Start by installing (if not already) this package with npm i gameart-task-kilian.
  2. Run the code using npm run jsfunctions.
  3. Access your IDEs terminal to view the output from the used functions.

Written Functions

1. Returns all unique numbers, ordered from larger to smallest

The function getUniqueNumbers takes an array as input and returns a new array containing only the unique numbers from the original array, in descending order.

function getUniqueNumbers(array) {
  const uniqueNumbers = array.filter(
    (number, index) => array.indexOf(number) === index
  );

  const sortedNumbers = uniqueNumbers.sort((a, b) => b - a);

  return sortedNumbers;
}

2. Returns all numbers, where each of them is multiplied by two

The function multiplyNumbersByTwo multiplies each number in the input array by two and returns a new array with the multiplied values.

function multiplyNumbersByTwo(array) {
  return array.map((number) => number * 2);
}

3. Returns all odd numbers

The function getOddNumbers filters out all the odd numbers from the input array and returns a new array with only the odd values.

function getOddNumbers(array) {
  return array.filter((number) => number % 2 !== 0);
}

4. Returns sum of all numbers

The function getSumOfNumbers uses reduce to calculate the sum of all numbers in the input array and returns the total sum.

function getSumOfNumbers(array) {
  return array.reduce((sum, number) => sum + number, 0);
}

5. Returns sum of all numbers that are divisible by 3

The function getSumOfNumbersDivisibleByThree uses reduce to calculate the sum of all numbers in the input array that are divisible by 3.

function getSumOfNumbersDivisibleByThree(array) {
  return array.reduce((sum, number) => {
    if (number % 3 === 0) {
      return sum + number;
    }
    return sum;
  }, 0);
}