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

coverty

v1.0.8

Published

HTTP client for API testing and fake data generator

Downloads

14

Readme

Coverty

It's time for testing, and to check your endpoint status with the help of your favorite testing framework 🧪.

Instalation

Installation in your project 📁

npm install -D coverty

Usage 🎯

Import the module with coverty or custom name from library 📦

Create a client base urls and set globals properties for requests ⚡

// ES MODULES
import converty from 'converty'

// COMMON JS
const coverty = require('converty').default

// Implementation

const client = converty.setup({
  baseUrl: 'https://myurl/api',
  // Optional global start
  globalHeaders: {
    'myCustomGlobalHeader': 'value'
  },
  globalBody: {
    'myCustomGlobalBody': 'value'
  },
  globalQuerys: {
    'myCustomGlobalQuerys': 'value'
  }
  // Optional global end
})

/* The second parameter of all methods receives an options object similar to the global, but local, so that they only work on this client invocation. */

client.get('/posts', options...).then((results) => {
    console.log(results.information.timeFetching) // in milliseconds
}).catch((err) => {
    console.error(err)
})

The methods 🧩

All methods can be used without creating the client, but if you don't want to repeat certain things, it's better to create the client.

Documentation for http methods taken from here.

| Method library | Description | | --------------------- | ------------------------------------------------------------ | | coverty.generator | It is a set of methods to obtain fake data to interact with our APIs, they are stored locally and are generated from Mockaroo. | | coverty.setup | Instantiate certain global parameters and the base of your url to which you are going to make requests. Returning an object with methods named the same as http verbs. | | coverty.get | The GET method requests a representation of the specified resource. Requests using GET should only retrieve data. | | coverty.post | The POST method submits an entity to the specified resource, often causing a change in state or side effects on the server. | | coverty.put | The PUT method replaces all current representations of the target resource with the request payload. | | coverty.delete | The DELETE method deletes the specified resource. | | coverty.patch | The PATCH method applies partial modifications to a resource. |

The fake data generator has all its methods named intuitively for use. You can generate all of the following data just by calling the method.

  • Animals
  • Image base64 string
  • Boolean
  • Cars brands
  • Hex colors
  • Colors names
  • Cities
  • Country codes
  • Dates
  • SQL datetime
  • Emails
  • Firts names
  • Last names
  • Genders
  • Movie title
  • Numbers
  • Passwords
  • Text (optional max param object value from method)
  • Timestamp
  • Timezone
  • MongodbId
// ES MODULES
import converty from 'converty'

// COMMON JS
const coverty = require('converty').default

// Example generate a email

const emailGenerated = converty.generator.getEmail() // Random email

console.log(emailGenerated)

This only returns 1 element, if you want more than one you could click and fill in an array to send your data if you need it

// ES MODULES
import converty from 'converty'

// COMMON JS
const coverty = require('converty').default

// Example generate array of emails

const data = []

for(let i = 0; i < 5; i++){
  data.push(coverty.generator.getEmail())
}

console.log(data)

The responses ⛵

  1. Response.status: status code of the request http.
  2. Response.headers: headers response by the server.
  3. Response.data: data response by the server.
  4. Response.information.timeFetching: server response time in milliseconds.
  5. Response.information.timeTranformationJson: time to transform the JSON.
  6. Response.information.url: url where the request was directed.
  7. Response.information.sentHeaders: headers sent to server.
  8. Response.information.sentBody: body sent to server.
  9. Response.information.sentQuerys: query sent to server.

Thanks to typescript you will be able to have autocompletion in visual studio code and other popular IDEs, so you can easily extract the api responses and some performance information. Just like typescript helps with module methods for easy use.