4.0.0 • Published 18 days ago

spur-common v4.0.0

Weekly downloads
6
License
MIT
Repository
github
Last release
18 days ago

A Node.js library of common modules used to create common applications.

NPM Version NPM Install Size NPM Downloads

About the Spur Framework

The Spur Framework is a collection of commonly used Node.JS libraries used to create common application types with shared libraries.

Visit NPMJS.org for a full list of Spur Framework libraries >>

Topics

Quick start

Installing

$ npm install spur-ioc --save
$ npm install spur-common --save

Usage

src/injector.js

const spur       = require('spur-ioc');
const spurCommon = require('spur-common');

module.exports = function(){

  // define a  new injector
  const ioc = spur.create('demo');

  // register already constructed objects such as globals
  ioc.registerDependencies({
  });

  // register folders in your project to be autoinjected
  ioc.registerFolders(__dirname, [
    'demo/'
  ]);

  // THIS IS THE IMPORTANT PART: Merge the spur-common dependencies to your local container
  ioc.merge(spurCommon())

  return ioc;
}

start.js

const injector = require('./src/injector');

injector().inject(function (UncaughtHandler, Logger) {

  Logger.info('Starting app...');

  // Here you would inject your dependencies like WebServer or runtime class and start it.

  // Enabled the UncaughtHandler
  UncaughtHandler.listen();

});

Available dependencies in injector

To see the latest list of the default dependencies that are injected, check out the injector.js file. Here is a short list of of all of the dependencies available:

System dependencies

NameOriginal Module NameDescription
fsfsNode file system
pathpathNode path module
nodeProcessprocessNode process module
consoleconsoleJavaScript Console
JSONJSONJavaScript JSON library

Libraries

List of external dependencies used and exposed by spur-common. They can be found at npmjs.org using their original names.

NameOriginal Module Name
Promisebluebird
superagentsuperagent
FormDataform-data
SpurErrorsspur-errors

Local dependecies

All of the files under the src/ directory are made available when this module is merged into another injector. The following list are the notable dependencies available.

NameSourceDescription
BaseDelegatecodeA utility class used to create classes with delegates that can be allow us to replace implementations dynamically and allow for plugins. For an example, take a look at Logger.
UncaughtHandlercodeSimple module that catches uncaught errors when initialized.
FixtureUtilcodeFixtures util that allows you to read test files from a specific directory.
HTTPServicecodeAn extension of the superagent module to support promises and other nice enhancements to make HTTP requests simpler to process.
LoggercodeAn implementation of a logger that extends console.log and makes it so you can add plugins for logging to different sources.
fsPromisecodeA wrapper for the Node fs module that adds promises to the module.
UtilscodeA collection of random utilities.

Contributing

We accept pull requests

Please send in pull requests and they will be reviewed in a timely manner. Please review this generic guide to submitting a good pull requests. The only things we ask in addition are the following:

  • Please submit small pull requests
  • Provide a good description of the changes
  • Code changes must include tests
  • Be nice to each other in comments. :innocent:

Style guide

The majority of the settings are controlled using an EditorConfig configuration file. To use it please download a plugin the plugin for your editor of choice.

All tests should pass

To run the test suite, first install the dependancies, then run npm test

$ npm install
$ npm test

License

MIT

4.0.0

18 days ago

3.0.3

6 months ago

3.0.2

11 months ago

3.0.1

11 months ago

2.1.3

1 year ago

3.0.0-rc.1

1 year ago

3.0.0

1 year ago

2.1.2

1 year ago

2.1.1

2 years ago

2.0.1

2 years ago

2.1.0

6 years ago

2.0.0

7 years ago

2.0.0-rc.1

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

1.0.0-rc.2

7 years ago

1.0.0-rc.1

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.3.0-rc.1

8 years ago

0.2.0

8 years ago

0.1.16

9 years ago

0.1.15

9 years ago

0.1.14

9 years ago

0.1.13

9 years ago

0.1.12

9 years ago

0.1.11

9 years ago

0.1.10

9 years ago

0.1.9

9 years ago

0.1.8

9 years ago

0.1.7

9 years ago

0.1.6

9 years ago

0.1.5

9 years ago

0.1.4

9 years ago

0.1.3

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago

0.0.9

9 years ago

0.0.8

9 years ago

0.0.7

9 years ago

0.0.6

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago