1.0.9 • Published 7 months ago

auto-barrel-sync v1.0.9

Weekly downloads
-
License
ISC
Repository
-
Last release
7 months ago

Auto Barrel Sync

License

npm version

Description

auto-barrel-sync is a Node.js module that simplifies the process of auto-generating a barrel file for your project. A barrel file is used to consolidate and export multiple modules from different folders, making it easier to import them in other parts of your application.

Installation

You can install auto-barrel-sync using npm:

npm install auto-barrel-sync

Usage

To use auto-barrel-sync in your Node.js project, follow these steps:

1 - Create your desired folder structure inside src.

Example:

  • src
    • controllers
    • services
    • utils

2 - Inside each folder, create your modules.

Example:

  • src
    • utils
      • calculatorUtil.js

3 - Inside calculatorUtil.js create your functions and export as an object with a name.

Example:

const sum = (a, b) => a + b;
const subtract = (a, b) => a - b;

module.exports = {
  name: 'CalculatorUtil',
  sum,
  subtract
}

4 - Import the package where you want to use the modules:

const Barrels = require('auto-barrel-sync');

The barrel object will contain the exported modules from your specified folders such as CalculatorUtil.

So, you can also use as:

const { Utils } = require('auto-barrel-sync');
const { CalculatorUtil } = Utils;

CalculatorUtil.sum(10, 20);
CalculatorUtil.subtract(20, 30);

Notice that the the auto-barrel-sync use the name you added when you create an object to export your functions.

See more examples of usage bellow:

const { Services, Controllers } = Barrels;
const { UserService, AuthService } = Services;
const { UserController, AuthController } = Controllers;

Configuration

By default, auto-barrel-sync looks for folders in the src directory. At the moment you cannot customize.

License

This project is licensed under the ISC License.

Contributing

Contributions are welcome! If you have any suggestions, bug reports, or feature requests, please open an issue or create a pull request on the GitHub repository.

Acknowledgments

Node.js: The JavaScript runtime used to build this package.

Author

Rafael Tedesco

1.0.9

7 months ago

1.0.8

7 months ago

1.0.7

7 months ago

1.0.6

7 months ago

1.0.5

7 months ago

1.0.4

7 months ago

1.0.3

7 months ago

1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago