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

ndapp

v1.0.17

Published

ndapp - its node application starter helper. It helps you do not write long requires, parse command line arguments, use application with components hierarchy, define your tools or favourte modules to fast access to him (without require in every new file)

Downloads

7

Readme

ndapp - its node application starter helper. It helps you do not write long requires, parse command line arguments, use application with components hierarchy, define your tools or favourte modules to fast access to him (without require in every new file)

ndapp create a global variable app - it's yours application with with everything you need

In new app by default avaliable few modules: path, fs-extra, os, lodash, moment To use them, in every

const ndapp = require("ndapp");

Create application

ndapp(options)

Where options - is object with fields, you can omit any option:

  • app - instance of your app, use base class:

    class MyApp extends ndapp.Application {
    };
      
    ndapp({ app: new MyApp() });
  • arguments - command line arguments You can define enum for your argument list, and define options to parse arguments (parsing is provided by module minimist)

    const ARGUMENTS = new ndapp.enum({
        "ARG1": "arg1",
        "ARG2": "arg2"
    });
    
    ndapp({
        arguments: {
            enum: ARGUMENTS,
            options: {
                boolean: [
                    ARGUMENTS.ARG1,
                    ARGUMENTS.ARG2
                ],
                default: {
                    [ARGUMENTS.ARG1]: false,
                    [ARGUMENTS.ARG2]: false
                }
            }
        }
    });

    If you provide a enum for arguments, you can acess to arguments by these methods:

    console.log(app.arguments[app.enums.arguments.ARG1]);
    console.log(app.arguments.ARG1);

    Otherwise, you always acess to arguments by it's names (how you will write it in console)

    console.log(app.arguments.arg1);

    app.arguments - it's a minimist result (for example, you can acess to undefined args by app.arguments._)

  • enums - define your own enums

    ndapp({
        enums: {
            myEnum: new ndapp.enum(["MY_ENUM1", "MY_ENUM2"])
        }
    });
  • constants - define your own constants

    ndapp({
        constants: {
            "MY_CONSTANT": 123
        }
    });
  • libs - define libs

    ndapp({
        libs: {
            express: require("express")
        }
    });
    
    const application = app.libs.express();

    Default libs path os fs (fs-extra) _ (lodash) moment (moment.js)

  • tools - define any function/classes, what you need

    ndapp({
        tools: {
            convert: x => x * 100
        }
    });
    
    const result = app.tools.convert(20);
  • components - define application components

    class MyComponentApp extends ndapp.ApplicationComponent {
        constructor(options) {
            // ...
        }
    };
    
    ndapp({
        components: [
            new MyComponentApp({ a: 1})
        ]
    });

Simpliest application will looks like:

ndapp()

const data = app.tools.json.load("mydata.js");

Complex example:

const ARGUMENTS = new ndapp.enum({
	"MY_ARG": "myarg"
});

class MyApp extends ndapp.Application {
};

ndapp({
	info: {
		name: "abb-server",
		version: "2.0.0"
	},
	app: new MyApp(),
	arguments: {
		enum: ARGUMENTS,
		options: {
			boolean: [
				ARGUMENTS.MY_ARG
			],
			default: {
				[ARGUMENTS.MY_ARG]: true
			}
		}
	},
	enums: {
	},
	constants: {
	},
	libs: {
	},
	tools: {
	},
	components: [
	]
});