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 🙏

© 2026 – Pkg Stats / Ryan Hefner

jpex-folder

v2.0.0

Published

Auto-register Jpex factories

Readme

Jpex Folders Plugin

Automatically register factories/services from files in folders.

Installaction

npm install jpex-folder

Usage

var Jpex = require('jpex');
var plugin = require('jpex-folder');
Jpex.use(plugin);

// Register all factories in current_working_directory/factories
Jpex.register.folder('factories', options);

This means you can organise your application in a logical manner and then have all dependencies automatically loaded and injected into your jpex classes.

Options

The Options parameter takes the following options:

type

The type of dependency you want to register them as. If not specified it will register all functions as factories and anything else as a constant. Valid values are factory, service, constant, 'auto'

lifecycle

The default lifecycle to register a factory as. This can either be a string or a number.

Jpex.register.folder('factories', { lifecycle : 'application' });
Jpex.register.folder('services', { lifecycle : 1 });
var constants = require('jpex/src/constants');
Jpex.register.folder('other', { lifecycle : constants.APPLICATION });

If not specified it will default to 'instance'.
It is also possible to set a specific lifecycle within the file being loaded in...

// factories/someFactory.js
module.exports = function(){
  // do some factory stuff
};
module.exports.lifecycle = 'application';

this will override the default lifecycle for that file.

dependencies

Although not an option it is worth noting here that you can also specify dependencies on the individual files...

// factories/someFactory.js
module.exports = function () {
  // ...
};
module.exports.dependencies ['foo', 'bah'];

prefix

A prefix to add to the start of each dependency

suffix

A suffix to add to the end of each dependency

###prefixFolder
When adding sub folders, this will prepend the folder name to the dependency, so main folder with a sub.js file will be registered as mainSub, for example.

###pattern
A glob pattern to match by. This defaults to '**/*.js'

###transform
function(base, folders, extension, options){}
A function that will transform the filename into the name of the dependency. This is entirely optional and will be handled automatically using the above option values if omitted.
The function takes 4 parameters: the file name (without the folders or file extension), an array of folders leading to the file, the file extension (.js). and the main options object.
The this object will be the Class the folders are being registered against.
The value returned by this function will be used as the dependency name.

###register
function(filename, content, options){} Another optional function that takes the name of the dependency and the contents of the related file and registers the dependency against the class.