diff --git a/package-lock.json b/package-lock.json index ca3c872..d3fe286 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@athenna/common", - "version": "5.28.0", + "version": "5.29.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@athenna/common", - "version": "5.28.0", + "version": "5.29.0", "license": "MIT", "dependencies": { "@fastify/formbody": "^8.0.2", @@ -1915,6 +1915,31 @@ "readable-stream": "^3.4.0" } }, + "node_modules/bl/node_modules/buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, "node_modules/bl/node_modules/readable-stream": { "version": "3.6.2", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", @@ -1966,10 +1991,9 @@ } }, "node_modules/buffer": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", - "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", - "devOptional": true, + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", "funding": [ { "type": "github", @@ -1985,9 +2009,11 @@ } ], "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "base64-js": "^1.3.1", - "ieee754": "^1.1.13" + "ieee754": "^1.2.1" } }, "node_modules/builtins": { diff --git a/package.json b/package.json index 7594f47..c7dff64 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@athenna/common", - "version": "5.28.0", + "version": "5.29.0", "description": "The Athenna common helpers to use in any Node.js ESM project.", "license": "MIT", "author": "João Lenon ", diff --git a/src/helpers/Path.ts b/src/helpers/Path.ts index a710bd2..af8bddd 100644 --- a/src/helpers/Path.ts +++ b/src/helpers/Path.ts @@ -46,6 +46,8 @@ export class Path extends Macroable { seeders: 'src/database/seeders', migrations: 'src/database/migrations', lang: 'src/lang', + events: 'src/events', + listeners: 'src/events/listeners', resources: 'resources', views: 'resources/views', locales: 'resources/locales', @@ -265,6 +267,38 @@ export class Path extends Macroable { return this } + /** + * Return the events path of your project. + */ + public static events(subPath: string = sep): string { + return this.pwd(this.dirs.events + sep + normalize(subPath)) + } + + /** + * Set the directory of events folder. + */ + public static setEvents(directory: string): typeof Path { + this.dirs.events = directory + + return this + } + + /** + * Return the listeners path of your project. + */ + public static listeners(subPath: string = sep): string { + return this.pwd(this.dirs.listeners + sep + normalize(subPath)) + } + + /** + * Set the directory of listeners folder. + */ + public static setListeners(directory: string): typeof Path { + this.dirs.listeners = directory + + return this + } + /** * Return the node_modules path of your project. */ diff --git a/src/types/PathDirs.ts b/src/types/PathDirs.ts index c213c59..abfdb8b 100644 --- a/src/types/PathDirs.ts +++ b/src/types/PathDirs.ts @@ -36,6 +36,8 @@ export interface PathDirs { seeders?: string migrations?: string lang?: string + events?: string + listeners?: string resources?: string apiResources?: string views?: string diff --git a/tests/unit/helpers/PathTest.ts b/tests/unit/helpers/PathTest.ts index 20bac89..5678633 100644 --- a/tests/unit/helpers/PathTest.ts +++ b/tests/unit/helpers/PathTest.ts @@ -179,6 +179,8 @@ export default class PathTest { .setSeeders('build/src/database/seeders') .setMigrations('build/src/database/migrations') .setLang('build/src/lang') + .setEvents('build/src/events') + .setListeners('build/src/events/listeners') .setResources('build/resources') .setApiResources('build/src/resources') .setViews('build/resources/views') @@ -226,6 +228,8 @@ export default class PathTest { assert.isTrue(Path.migrations().endsWith(`build${sep}src${sep}database${sep}migrations`)) assert.isTrue(Path.resources().endsWith(`build${sep}resources`)) assert.isTrue(Path.views().endsWith(`build${sep}resources${sep}views`)) + assert.isTrue(Path.events().endsWith(`build${sep}src${sep}events`)) + assert.isTrue(Path.listeners().endsWith(`build${sep}src${sep}events${sep}listeners`)) assert.isTrue(Path.locales().endsWith(`build${sep}resources${sep}locales`)) assert.isTrue(Path.apiResources().endsWith(`build${sep}src${sep}resources`)) assert.isTrue(Path.nodeModules().endsWith(`build${sep}node_modules`))