Giter VIP home page Giter VIP logo

wizard's Introduction

wizard

Fast, flexible autoload for express dependencies using the power of glob.

Why

Loading dependencies and including them into express shouldn't be hard. Sometimes you need a clean and powerful interface like the one provide by the glob package to do the job.

That's why express-wizard exists.

Install

You can get it on npm.

$ npm install express-wizard --save

// or

$ yarn add express-wizard

Usage

var Wizard = require('express-wizard');

var instance = new Wizard()
                      .inject('model/**/*.js')
                      .inject(['controller/**/*.js', 'service/**/*.js'])
                      .inject('stop.js')
                      .exclude('middleware/**/*.js')
                      .exclude('start.js')
                      .into(app);
// app.model.foo
// app.model.bar
// app.controller.foo
// app.controller.bar
// app.service.foo
// app.service.bar
// app.stop

Options

Defaults

new Wizard({
  cwd: process.cwd(),
  logger: console,
  verbose: true,
  loggingType: 'info',
  defaultExclusion: []
});

Logging

logger - Defaults to console, this can be switched out. verbose - On by default, set to false for no logging loggingType - Set the type of logging, defaults to info

Base Directory (cwd)

Wizard will simply use a relative path from your current working directory, however sometimes you don't want heavily nested files included in the object chain, so you can set the cwd:

new Wizard()
  .include('project/model/**/*.js') // ./project/model/foo.js
  .into(app);

would result in:

app.project.model.foo

so using the cwd option:

new Wizard({cwd: 'project'})
  .include('model/**/*.js') // ./project/model/foo.js
  .into(app);

would give us:

app.model.foo

Semver

Until wizard reaches a 1.0 release, breaking changes will be released with a new minor version. For example 0.6.1, and 0.6.4 will have the same API, but 0.7.0 will have breaking changes.

Tests

To run the test suite, first install the dependencies, then run npm test:

$ npm install
or
$ yarn install

$ npm test

Resources

License

MIT License ยฉ Ivan Santos

wizard's People

Contributors

eduardolundgren avatar pragmaticivan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

wizard's Issues

Perform glob loading in parallel injecting the files by group

Every time it performs a .inject(), it would create an array of files. After using into, it should follow the order of injects.
ex:

wizardInstance.inject('middleware/**/*.js')
    .inject('controller/**/*.js')
    .into(app);

It should first inject middleware to guarantee the order, so middlewares are going to be applied on app before controllers.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.