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

node-setup-utility

v2.0.5

Published

Command Line Tool For Making Backend Service With Less Coding Using Node.js

Downloads

2

Readme

Node-Utility

About:

Installation:

npm i -g node-setup-utility

Usage:

1. Set up new NODE JS Project:

Step 1 : Intilize Node Project By Running Following Command and Give Necessary Details For package.json

npm init

Step 2 : Checkout Help Section Of The Command For More Understanding Of The Tool(Optional)

node-project -h
node-project --help

Step 3 : Run Following Command For Set Up Project, Enter Port Number to run your backend when asked

node-project basic

Step 4 : No more Stpes, That's it :star_struck:. Once last command completes it's execution, all the files will be generated.

You can run your project by typing following command. It will give you the url in the console on which your backend is working :airplane:.

node index.js

2. Establish MongoDB Connection:

Step 1 : Run Following Command, It will ask for mongoDB url and DB name, you will need to enter it when asked

node-project mongocon

Step 2 : Once last command completes it's execution, connection file can be accessed at database/mongodbConnection.js.

Now You can use it anywehre in the project, recommanded way is to include in in the app.js file using following way.

require("path of your database/mongodbConnection.js");

Note : You can access your input and also modify in .env file.

3. Establish MySQL Connection:

Step 1 : Run Following Command, It will ask for MySQL connection configurations, you will need to enter it when asked

node-project mysqlcon

Step 2 : Once last command completes it's execution, connection file can be accessed at database/mysqlConnection.js.

Now You can use it anywehre in the project, recommanded way is to include in in the app.js file using following way.

require("path of your database/mysqlConnection.js");

Note : You can access your inputs and also modify in .env file.

4. Get Functions To Work With JWT:

:warning: To Use this, You will need our helper function which is only available if you setup project using our tool. In Future, we will add functionality to setup only helper functions, but currently you can't use this feature if you haven't setup your project using our tool.

Step 1 : Run Following Command, It will ask for JWT Secret

node-project jwt

Step 2 : Once last command completes it's execution, JWT functions will be available at middleware/auth.js.

Default Expiry is set to 24h, you can change it in the .env file.

How to Use this functions ?

  • Generate JWT Token : Import generateJWT function from middleware.auth.js and Prepare Payload as pass it to function as below

example:

const { generateJWT } = require("./middleware/auth.js");

// create payload
const payload = {
        name : "demo",
        email : "email",
        isSuperAdmin : false,
};

// generate token
const token = generateJWT(payload);
  • payload can contain any information of your choice, which you can access when decrypting token.
  • you can send this token to client and when client access any route which require authorized user, you can use our authMiddleware, which will verify user is authorized or not, if authorized you can access it's payload which you set during generating that token in your route. If not authorized it will generate error.

example:

router.patch("/profile", validator(updateUserSchema), authMiddleware, Update);
  • verify token by your self :
const to = require("await-to-js").default;
const { verifyToken } = require("./middlewares/auth");

// access token
const { token } = req.body;
// verify token
const [error, payload] = await to(verifyToken(token));
  • if token valid in above code, error object will be null and you can use payload. Otherwise, error will have some message.

Note : You can access your inputs and also modify in .env file.