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

beatific

v1.2.2

Published

No need to install mongoose, bcrypt, jsonwebtoken, helmet, compression, morgan. This library does every functionality of them for you. And it can generate dockerfile for project as well.

Downloads

10

Readme

Beatific

npm version Build Status MIT License PRs Welcome npm

A single npm package which satisfies the need for the following packages:

  • mongoose => For establishing connection to your MongoDB and producing mongoose models.
  • bcryptjs => For hashing and verifying hashes.
  • helmet => For securing Express apps by setting various http headers.
  • compression => For the compression of route propagation.
  • jsonwebtoken => For generating and verifying JWTs.
  • morgan => For logging every request made to your backend.

It also generates the dockerfile for your project :)


Usage:

Installation:

npm install --save beatific

API:

var beatific = require("beatific");

MongoDB/Mongoose Functionality:

  • Connect to a MongoDB

Parameters: MongoDB URI

beatific.mongoConnect(dbURI)
.then(db => console.log("Connected to the DB..."))
    .catch(err => console.error("Error connecting to the DB!"));
  • Create a mongo schema and automatically generate a mongoose.model for it

Parameters: Schema name, schema object, db collection name (optional)


let userSchema = {
   name: {
      type: String,
      required: true
   },
   email: {
      type: String,
      required: true,
      unique: true
   }
};

beatific.mongoModelGen('User', userSchema, "users")
.then(model => console.log("mongoose.model generated for user schema"))
     .catch(err => console.error("Some problem occurred"));

What this does behind the scenes


const mongoose = require("mongoose");

let userSchema = {
   name: {
      type: String,
      required: true
   },
   email: {
      type: String,
      required: true,
      unique: true
   }
};

let schema = new mongoose.schema(userSchema);

return mongoose.model('User', schema, "users");

JWT functionality:

  • Signing/Generating the token:

Parameters: data, secret, expiresIn (optional)

beatific.generateJWT({message: "Hey there"}, 'something_secret', '4d')
.then(token => console.log("Here's the token " + token))
   .catch(err => console.error("Some problem occurred"));
  • Verifying/Decoding the token:

Parameters: token, secret

 beatific.decodeJWT('my_token_1234321', 'something_secret')
.then(decoded => console.log("Here's the decoded token " + decoded))
   .catch(err => console.error("Some problem occurred"));

Bcrypt Functionality:

  • Hashing some data:

Parameters: data, salt rounds (default=10)

beatific.hashGen("hey there", 8)
.then(hash => console.log("Here's the hash " + hash))
    .catch(err => console.error("Some problem occurred"));
  • Verifying/Comparing some data and corresponding hash:

Parameters: hashed data, inputData

beatific.hashCheck("$adfdsf23243546524", "my password may be")
.then(valid => console.log("Status of check: " + valid))
   .catch(err => console.error("Some problem occurred"));

Use logger

Parameters: loggerType (default = "dev")

//In your main .js file

var app = express();
loggerType = "short"; // For example

app.use(beatific.logger(loggerType));

Use helmet:

// In your main .js file
var app = express();

app.use(beatific.helmet());

Use compression:

// In your main .js file
var app = express();

app.use(beatific.compression());

Generate Dockerfile for the project

Parameters: dockerfile_name (default="dockerfile"), portNumber, startCommand (default="npm start")

Just run this once in your main .js file:

beatific.dockerGen("dockerfile.dev", 8000, "npm test");

License

MIT