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

@antiers/product-package

v1.3.2

Published

Exchange all common utilities includes in this package

Downloads

866

Readme

product-package

Exchange all common utilities includes in this package

Installation

npm i @antiers/product-package
yarn add @antiers/product-package

Example usage

import * as helpers from '@antiers/product-package'

const redisCredentials = {
    host: "",
    port:"",
    jwtsecret:""
}
const kafkaCredentials = {
    clientId: "",
    brokers: [""]
}
const dbCredentials = {
    host: "",
    user: ""
    password:"",
    database:"",
    connectionLimit: "",
    port:"",
    timezone: ""
    
}
const mailCredentials = {
    host: "",
    port: "",
    user: "",
    password:"",
    secure: ""
}

let DbHelper, RedisHelper, KafkaHelper, MailHelper;

//function to create connection by passing credentials to helper classes
async function createConnection() {
    DbHelper = await new helpers.Dbhelper(DbCredentials)
    RedisHelper = await new helpers.redisHelper(redisCredentials)
    KafkaHelper = await main.KafkaHelper(rabbitMqCredentials)
    MailHelper = await main.MailHelper(kafkaCredentials)
}

/**
redis function to setString 
@param key
@param value
@param expires
**/
await RedisHelper.setString(key,value,expires);

/**
redis function to getString 
@param key
**/
const getValuefromRedis = await RedisHelper.getString(key)

/**
Kafka function to produce message
@param topic
**/
await KafkaHelper.produceMessage(topic, [
    {
        value: 'message1'
    },{
        value: 'message2'
    }
])

/**
Kafka function to consume message
@param topic
**/
await kafka.consumeMessage(topic);

/**
Mail helper function to send mail 
@param receipient address
@param subject
@param message
@param template
**/
await MailHelper.sendMail(receipient_address, subject, message, template)

/**
Define Model
@param query
**/
const User = db.sequelize.define(tablename, {
            // Model attributes are defined here
            firstName: {
                type: DataTypes.STRING,
                allowNull: false
            },
            lastName: {
                type: DataTypes.STRING
                // allowNull defaults to true
            },
            age: {
                type: DataTypes.INTEGER,
                allowNull: false
            }
        }, {
            // Other model options go here
            timestamps: false
        });
        
/**
 * Simple query to select all records from table using model
 **/
const data = await User.findAll();

/**
 * jwtMiddleware
 **/
public jwtMiddleware = helpers.jwtValidateToken()
this.app.get('/', this.jwtMiddleware, (req: any, res: any) => {
    res.send("user token validated")
})
public adminMiddleware = helpers.adminValidateToken()
this.app.get('/', this.adminMiddleware, (req: any, res: any) => {
    res.send("admin token validated")
})

NOTE

  • Before using any other function make sure that you pass credentials for all helper classess otherwise you will got error.
  • Once credentials passed you can use any helper class and its function as shown in above examples.