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

@appbuckets/server-builder

v0.2.33

Published

AppBuckets Server Builder Class

Downloads

27

Readme

AppBuckets - ServerBuilder

Description

This Module contains all the essentials Functions to create a responsive ServerBuilder
which manage the queues and protect any APIs queries with an authentication Token.


TokenManager()

This Class is a Token Manager. It is called with a secret parameter, and an options Object, which consinst of some settings for creating and managing the Token.

constructor(secretKey, options)

This is the constructor of the Class. You must pass a secret string and an Object which contains all the options you want to use to create your new Token.

Params

  • secretKey
    • type: String
    • description: The string the constructor use to generate the Token
  • options
    • type: Object
    • description: The options Object contains all the settings to create the new Token
    • expiresIn
      • type: String/Number
      • description: The default expire property. This is a string in a time format, like '15m' or '1 year'.
      • default: 15m
    • tokeSize
      • type: Number
      • description: Set the generated token size in bit
      • default: 128
    • tokenProp
      • type: String
      • description: Set the token property name that will be appended to paylod, and will be used to save the generated Token
      • default: token
    • appendRaw
      • type: Boolean
      • description: Set if must append raw generated token to payload
      • default: true
    • clockTollerance
      • type: String
      • description: Set the clock tollerance to evaluate expire date
      • default: 1m
    • issuer
      • type: String
      • description: Set the Token issuer, defining the host is sending and creating the token
      • default: localhost
    • audience
      • type: String
      • description: Set the Token audience, defining who is the receiver of the Token
      • default: client

generate(payload, options)

This Method generate a new Token, using provided payload Object and options Object.
If you want to use an already generated Token you can pass token parameter in options.

Params

  • payload
    • type: Object
    • description: Provided Payload Objects
  • options
    • type: Object
    • description: Options Object, which is similar to the constructor options object
    • default: TokenGenerationOptions
    • expiresIn
      • type: String
      • description: How long the Token is valid. If in the constructor is passed as a Number, a function will convert it into a String.
      • default: this.expiresIn
    • token
      • type: String
      • description: The token to use, if is not passed it will be autogenerated.
    • issuer
      • type: String
      • description: Issuer replacer
      • default: this.issuer
    • audience
      • type: String
      • description: Audience replacer
      • default: this.audience
    • expireAt
      • type: Number
      • description: If it is passed it will overwrite expiresIn param. This must be a date/time to calculate expiresIn

decode(token)

Return a new Token class that build a new JsonWebToken object starting from an encoded token

Params

  • token
    • type: String
    • description: The econdedToken the Function take from
    • default: varDefault

Token()

In this Class there are some Methods to check and use the Token generated. It requires as parameters the encodedToken and an options Object.

constructor(encodedToken, options)

The constructor is called with the ecodedToken to use, and some options to manage, that are the same of tokenManagerOptions by default.

Params

  • encodedToken
    • type: String
    • description: The encoded Token to use
  • options
    • type: Object
    • description:
    • default: tokenManagerOptions

valid()

This is a Property of the Token Class that return 'true' if the Token is valid.

expired()

This is a Property of the Token Class that return true if the the Token is expired.

encoded()

This is a Property of the Token Class that return a String which represents the encoded Token.

toString()

This is a Method of the Token Class that return a String which represents the decoded Token.


toObject()

This Method of the Token Class transform token into a plain Object, and return that Object.