Nail Polishing Minions

    srequire

    2.0.5 • Public • Published

    SRequire

    Simple requiring tool that loads everything you want from your cwd (or any other route you want to specify)

    Installation

    Installation is done using the npm install command:

    $ npm install srequire
    

    Usage

    1. If you want, you could specify baseRoutes on your cwd: On JavaScript (baseRoutes.js):

      module.exports = {
          models: 'src/api/models',
          controllers: 'src/api/controllers',
          uploads: 'src/common/uploads',
          logger: 'src/common/logger'
      };

      Or JSON (baseRoutes.json):

      {
          "models": "src/api/models",
          "controllers": "src/api/controllers",
          "uploads": "src/common/uploads",
          "logger": "src/common/logger"
      };

      Or load them only 1 time for all your project:

      const srequire = require('srequire');
      
      srequire.serBaseRoutes({ models: 'src/api/models' });
    2. Require your modules:

      const srequire = require('srequire');
      // If you specified on your base route a baseDir, you can use it like this
      const users = srequire('models/users');
      const errors = srequire('src/api/lib/tools/pepe/xxx/errors');
      
      // You can also set modules as baseRoutes!
      const Logger = srequire('logger');
      
      Logger.info('Works!... must work..');
    3. Use it to join paths to your cwd:

      const { readFileSync } = require('fs');
      const { joinToCWD } = require('srequire');
      
      // You can also use your baseRoutes
      const dirPath = joinToCWD('/any/dir', 'you/want', 'pepe.json');
      const config = JSON.parse(readFileSync(dirPath));
    4. Use it to join paths to your baseRoutes or any path as you do with the module path:

      const user = await users.getOne({...});
      const { join } = srequire('srequire');
      const uploadsDir = join('uploads', user.uploads);

    Install

    npm i srequire

    DownloadsWeekly Downloads

    0

    Version

    2.0.5

    License

    ISC

    Unpacked Size

    4.89 kB

    Total Files

    4

    Last publish

    Collaborators

    • starblizzard