diff --git a/package-lock.json b/package-lock.json index be5e231..5f84d54 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@athenna/common", - "version": "4.39.0", + "version": "4.40.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@athenna/common", - "version": "4.39.0", + "version": "4.40.0", "license": "MIT", "dependencies": { "@fastify/formbody": "^7.4.0", diff --git a/package.json b/package.json index 59cf050..ad7386e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@athenna/common", - "version": "4.39.0", + "version": "4.40.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 1c36c99..d976d45 100644 --- a/src/helpers/Path.ts +++ b/src/helpers/Path.ts @@ -21,6 +21,8 @@ export class Path { app: 'app', models: 'app/models', services: 'app/services', + jobs: 'app/jobs', + workers: 'app/workers', exceptions: 'app/exceptions', repositories: 'app/repositories', console: 'app/console', @@ -560,6 +562,38 @@ export class Path { return this } + /** + * Return the jobs' path of your project. + */ + public static jobs(subPath: string = sep): string { + return this.pwd(this.dirs.jobs + sep + normalize(subPath)) + } + + /** + * Set the directory of jobs folder. + */ + public static setJobs(directory: string): typeof Path { + this.dirs.jobs = directory + + return this + } + + /** + * Return the workers' path of your project. + */ + public static workers(subPath: string = sep): string { + return this.pwd(this.dirs.workers + sep + normalize(subPath)) + } + + /** + * Set the directory of workers folder. + */ + public static setWorkers(directory: string): typeof Path { + this.dirs.workers = directory + + return this + } + /** * Return the repositories' path of your project. */ diff --git a/src/types/PathDirs.ts b/src/types/PathDirs.ts index f0f19fe..92e850f 100644 --- a/src/types/PathDirs.ts +++ b/src/types/PathDirs.ts @@ -13,6 +13,8 @@ export interface PathDirs { app?: string models?: string services?: string + jobs?: string + workers?: string exceptions?: string repositories?: string console?: string diff --git a/tests/unit/PathTest.ts b/tests/unit/PathTest.ts index b3da5ad..42a9057 100644 --- a/tests/unit/PathTest.ts +++ b/tests/unit/PathTest.ts @@ -77,6 +77,8 @@ export default class PathTest { assert.equal(Path.console(), mainPath.concat(sep, 'console')) assert.equal(Path.models(), mainPath.concat(sep, 'models')) assert.equal(Path.services(), mainPath.concat(sep, 'services')) + assert.equal(Path.jobs(), mainPath.concat(sep, 'jobs')) + assert.equal(Path.workers(), mainPath.concat(sep, 'workers')) assert.equal(Path.validators(), mainPath.concat(sep, 'validators')) assert.equal(Path.exceptions(), mainPath.concat(sep, 'exceptions')) assert.equal(Path.repositories(), mainPath.concat(sep, 'repositories')) @@ -158,6 +160,8 @@ export default class PathTest { .setApp('build/app') .setModels('build/app/models') .setServices('build/app/services') + .setJobs('build/app/jobs') + .setWorkers('build/app/workers') .setValidators('build/app/validators') .setExceptions('build/app/exceptions') .setRepositories('build/app/repositories') @@ -196,6 +200,8 @@ export default class PathTest { assert.isTrue(Path.app().endsWith(`build${sep}app`)) assert.isTrue(Path.models().endsWith(`build${sep}app${sep}models`)) assert.isTrue(Path.services().endsWith(`build${sep}app${sep}services`)) + assert.isTrue(Path.jobs().endsWith(`build${sep}app${sep}jobs`)) + assert.isTrue(Path.workers().endsWith(`build${sep}app${sep}workers`)) assert.isTrue(Path.validators().endsWith(`build${sep}app${sep}validators`)) assert.isTrue(Path.exceptions().endsWith(`build${sep}app${sep}exceptions`)) assert.isTrue(Path.repositories().endsWith(`build${sep}app${sep}repositories`))