DEV Community

Nicolaas Nel
Nicolaas Nel

Posted on

1 1

Node-Essentials📦

Intro 🐱‍💻

Late last night I decided to finally publish my very own npm package, it's something I've wanted to do for a while now and I could never decide what to package.

While brainstorming I was busy working on a node.js app to process some data, the same code I've used in several projects.

This was it, the perfect package. I don't like searching for stuff I've already used and will use again in the future so I decided to package my most used node functions into a lightweight npm package.

To my surprise in under 10 hours it already hit over 800 downloads!🥳

About Node-Essentials 🐱‍🏍

This is a nodejs toolkit for doing asynchronous api calls, writing files to the system, starting up express-js servers and more coming soon.

Setup 🚧

Run:

npm install node-essentials

And include it in your app:

let node = require('node-essentials');
Enter fullscreen mode Exit fullscreen mode

Current Tools ⚙

writeToFile - Writes anything passed through to storage as any file.

The below sample is used to print out json data from an API call.

    node.writeToFile("tests", "writeToFile", "json", JSON.stringify(data));
Enter fullscreen mode Exit fullscreen mode

express - Set up an express-js server on the specified port and directory.

The "__dirname" is the relative path for the directory used by node and 3000 is the port it will serve to this is also the default express port.
This would serve the current root directory.

    node.express(3000, __dirname);
Enter fullscreen mode Exit fullscreen mode

get - A simple Async REST "get" request.

I will be adding more rest functions soon.

    async function get() {
    try {
        test = await node.get(
            "https://apiurlhere.com/",["api key desc", "api key value"])
            .then(console.log("done"));
    }
    finally {
        console.log(test);
    }
};
Enter fullscreen mode Exit fullscreen mode

Conclusion 🏁

The package contains functions I commonly use, I will be adding more simplified essential tools/functions as time goes on!

It's been an interesting journey making my first package and any feedback/suggestions of functions to add would be welcomed.

Where to get the package

NPM
Github

If you want to keep track of all my projects and endeavors I am super active over on Twitter and I'm always happy to give advice and lend some help.

FinalNecessity on Twitter 🍣

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay