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

every-utils

v1.1.5

Published

* [Sendy][1] * [Examples][2] * [subscribers][3] * [Parameters][4] * [subscribe][5] * [Parameters][6] * [Examples][7] * [subscribeMany][8] * [Parameters][9] * [unsubscribe][10] * [Parameters][11] * [deleteSubscriber][12] * [Parame

Downloads

54

Readme

Table of Contents

Sendy

This class handles all the Sendy API requests including email validation with VeryMail

Examples

const sendy = new Sendy(process.env.SEND_URL, process.env.SEND_API_KEY)

subscribers

This methods querys sendy for all subscribers from a particular list

Parameters

  • list_id {list_id: string} The list id to get subscribers from

    • list_id.list_id

Returns Array<Object> returns an array of subscribers from a particular list

subscribe

Parameters

  • subscription Object

    • subscription.name String? The contact name
    • subscription.email string he contact email address
    • subscription.list_id string The list id the contact should be subscribed to
    • subscription.verify boolean Whether to verify the email address or not, defaults to true (optional, default true)

Examples

try {
	 const { data } = await sendy.subscribe({
	name: 'Alex',
	email: '[email protected]',
	list_id: 'list_id',
 })
} catch (error) {
	throw error
}

Returns Promise<Boolean> returns true if the contact was successfully subscribed

subscribeMany

Parameters

  • emailList Array<Object> list of emails to subscribe
  • verify boolean Whether to verify the email addresses or not, defaults to true (optional, default true)

Returns Promise<Array<Object>> return all subscriptions successfully made

unsubscribe

Parameters

  • subscription Object

    • subscription.email String The contact email
    • subscription.list_id String The list id the contact should be unsubscribed from

Returns Promise<Boolean> returns true if the contact was successfully unsubscribed

deleteSubscriber

Parameters

  • subscription Object

    • subscription.email String The contact email
    • subscription.list_id String The list id the contact should be deleted from

Returns Promise<Boolean> returns true if the contact was successfully deleted

getSubscriberStatus

Parameters

  • subscription Object

    • subscription.email String The contact email
    • subscription.list_id String The list id the contact should be deleted from

Returns Promise<any> returns the status of the contact

getSubscriberCount

Parameters

  • subscription Object

    • subscription.email String The contact email
    • subscription.list_id String The list id the contact belongs

Returns Promise<Number> returns the number of active subscribers

getMailingLists

Parameters

Returns Promise<any> returns the subscriber details

getBrands

Returns Promise<any> returns the brands available on the platform

createCampaign

Parameters

  • options (CampaignOptions | any)

  • campaign Object

    • campaign.from_name String the 'From name' of your campaign
    • campaign.from_email String the 'From email' of your campaign
    • campaign.reply_to String the 'Reply to' of your campaign
    • campaign.title String the 'Title' of your campaign
    • campaign.subject String the 'Subject' of your campaign
    • campaign.track_opens String Set to 0 to disable, 1 to enable and 2 for anonymous opens tracking
    • campaign.track_clicks String Set to 0 to disable, 1 to enable and 2 for anonymous clicks tracking
    • campaign.plain_text String the 'Plain text version' of your campaign (optional) (optional, default '')
    • campaign.html_text String the 'HTML version' of your campaign
    • campaign.send_campaign String Set to 1 if you want to send the campaign as well and not just create a draft. Default is 0
    • campaign.list_ids String Required only if you set send_campaign to 1 and no segment_ids are passed in. List IDs should be single or comma-separated. The encrypted & hashed ids can be found under View all lists section named ID.
    • campaign.brand_id String Required only if you are creating a 'Draft' campaign (send_campaign set to 0 or left as default). Brand IDs can be found under 'Brands' page named ID
    • campaign.schedule_date_time String Campaign will be scheduled if a valid date/time is passed. Date/time format eg. June 15, 2021 6:05pm. The minutes part of the time has to be in increments of 5, eg. 6pm, 6:05pm, 6:10pm, 6:15pm.
    • campaign.schedule_timezone String Eg. 'America/New_York'.

Returns Promise<any> returns the campaign details

MongoDB

This is a class that handles all the mongo db methods and operations.

Examples

const mongo = new MongoDB(process.env.MONGO_URL, process.env.MONGO_DB)

db

This method returns the database client.

Examples

await db.collection(collection).findOne({ _id: id })

Returns Function database object

findById

This method finds a record from a mongo collection by id.

Parameters

Examples

const user = await mongo.findById('users', id);

Returns Array collection data by id.

findById

This method finds all record from a mongo collection.

Parameters

  • query Object

    • query.collection String name of the collection
    • query.searchColumn String the text to search for
    • query.searchValue String the text to search for
    • query.limit String the text to search for (optional, default 800)

Examples

const users = await mongo.searchBy({collection: 'users', searchColumn: 'name', searchValue: 'John', limit: 100});

Returns Array<Object> collection data.

findAll

This method finds all record from a mongo collection.

Parameters

  • collection String name of the collection
  • limit Number limit the number of records to return (optional, default 1000)

Examples

const users = await mongo.findAll('users', 100);

Returns Array<Object> collection data.

search

This method finds all record from a mongo collection.

Parameters

  • collection String name of the collection
  • searchText String the text to search for
  • limit Number limit the number of records to return (optional, default 1000)

Examples

const users = await mongo.search('users', 'John', 800);

Returns Array<Object> collection data.

save

This method saves a single record to a mongo collection.

Parameters

  • collection String name of the collection
  • body String data to save

Examples

await mongo.save('users', {
	name: 'John Doe',
email: '[email protected]',
age: 30,
	location: 'New York',
});

Returns Array<Object> database response.

saveMany

This method saves all records to a mongo collection.

Parameters

Examples

await mongo.save('users', [{
	name: 'John Doe',
email: '[email protected]',
age: 30,
	location: 'New York',
}, {...}, {...}]);

Returns Array<Object> array of records from collection.

update

This method saves all records to a mongo collection.

Parameters

  • collection String collection name
  • body String data to to be updated
  • id String id of the record to be updated

Examples

await mongo.update<User>('users', id, { name: 'John Doe' })

Returns Object object response from from collection.

updateMany

This method saves all records to a mongo collection.

Parameters

  • collection String collection name
  • filter String data to to be updated

Examples

await mongo.updateMany('users', [
 { _id: '603ca52d89c8f102ab323684', status: 'active' },
	{ _id: '603ca53389c8f102ab323685', status: 'inactive' },
])

Returns Object object response from from collection.

delete

This method deletes a record from a mongo collection.

Parameters

  • collection String collection name
  • id String id of the record to be updated

Examples

await mongo.delete('users', id)

Returns Object object response from deletion

deleteDuplicateByColumn

This method deletes all duplicate records from a mongo collection. Ideally you would want create appropriate indexes on the collection.

Parameters

  • collection String collection name
  • column String id of the record to be updated

Examples

await mongo.deleteDuplicateByColumn(
	'users',
	'email'
);

mongo sh command

db.contact.find().forEach(function(doc) {
	var email = doc.email;
	db.contact.deleteMany({ email: email, _id: { $ne: doc._id } });
});

Returns Object object response from deletion

deleteDuplicateByFilter

This method deletes all duplicate records from a mongo collection using given filter parameters.

Parameters

  • collection String collection name
  • filter String id of the record to be updated

Examples

const deleted = await mongodb.deleteMany("users", ['603ca52d89c8f102ab323684', '603ca53389c8f102ab323685'])

Returns Object object response from deletion

validateEmail

This method validates email address

Parameters

  • contact Object

    • contact.email String the email to be validated

Examples

const isValid = await validateEmail({
     email: '[email protected]',
 })

Returns boolean {Promise} a boolean value indicating if the email is valid or not

validateEmailBulk

This method validates all supplied email addresses.

Parameters

  • mailingList Array array of email objects to be verified

Examples

const { data } = await validateEmailBulk(
  {
    email: '[email protected]',
  },
  {
      email: '[email protected]',
  },
])

Returns Array object consisting of valid and invalid email addresses { valid: [], invalid: [] }

tld

Validate TLD

Parameters

  • email any

atIndex

remove email modifier