@athenna/http 4.16.0 → 4.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@athenna/http",
3
- "version": "4.16.0",
3
+ "version": "4.18.0",
4
4
  "description": "The Athenna Http server. Built on top of fastify.",
5
5
  "license": "MIT",
6
6
  "author": "João Lenon <lenon@athenna.io>",
@@ -72,14 +72,14 @@
72
72
  "#tests": "./tests/index.js"
73
73
  },
74
74
  "devDependencies": {
75
- "@athenna/artisan": "^4.27.0",
76
- "@athenna/common": "^4.26.0",
77
- "@athenna/config": "^4.11.0",
78
- "@athenna/ioc": "^4.12.0",
79
- "@athenna/logger": "^4.13.0",
80
- "@athenna/test": "^4.17.0",
75
+ "@athenna/artisan": "^4.30.0",
76
+ "@athenna/common": "^4.27.0",
77
+ "@athenna/config": "^4.12.0",
78
+ "@athenna/ioc": "^4.13.0",
79
+ "@athenna/logger": "^4.14.0",
80
+ "@athenna/test": "^4.18.0",
81
81
  "@athenna/tsconfig": "^4.12.0",
82
- "@athenna/view": "^4.10.0",
82
+ "@athenna/view": "^4.11.0",
83
83
  "@fastify/cors": "^8.4.2",
84
84
  "@fastify/helmet": "^11.1.1",
85
85
  "@fastify/rate-limit": "^8.1.1",
@@ -12,16 +12,4 @@ export declare class MakeControllerCommand extends BaseCommand {
12
12
  static signature(): string;
13
13
  static description(): string;
14
14
  handle(): Promise<void>;
15
- /**
16
- * Get the file path where it will be generated.
17
- */
18
- private getFilePath;
19
- /**
20
- * Get the destination path for the file that will be generated.
21
- */
22
- private getDestinationPath;
23
- /**
24
- * Get the import path that should be registered in RC file.
25
- */
26
- private getImportPath;
27
15
  }
@@ -16,7 +16,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
16
16
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
17
17
  };
18
18
  import { Path } from '@athenna/common';
19
- import { sep, resolve, isAbsolute } from 'node:path';
20
19
  import { BaseCommand, Argument } from '@athenna/artisan';
21
20
  export class MakeControllerCommand extends BaseCommand {
22
21
  static signature() {
@@ -27,42 +26,18 @@ export class MakeControllerCommand extends BaseCommand {
27
26
  }
28
27
  async handle() {
29
28
  this.logger.simple('({bold,green} [ MAKING CONTROLLER ])\n');
29
+ const destination = Config.get('rc.commands.make:controller.destination', Path.controllers());
30
30
  const file = await this.generator
31
- .path(this.getFilePath())
31
+ .fileName(this.name)
32
+ .destination(destination)
32
33
  .template('controller')
33
34
  .setNameProperties(true)
34
35
  .make();
35
36
  this.logger.success(`Controller ({yellow} "${file.name}") successfully created.`);
36
- const importPath = this.getImportPath(file.name);
37
+ const importPath = this.generator.getImportPath();
37
38
  await this.rc.pushTo('controllers', importPath).save();
38
39
  this.logger.success(`Athenna RC updated: ({dim,yellow} [ controllers += "${importPath}" ])`);
39
40
  }
40
- /**
41
- * Get the file path where it will be generated.
42
- */
43
- getFilePath() {
44
- return this.getDestinationPath().concat(`${sep}${this.name}.${Path.ext()}`);
45
- }
46
- /**
47
- * Get the destination path for the file that will be generated.
48
- */
49
- getDestinationPath() {
50
- let destination = Config.get('rc.commands.make:controller.destination', Path.controllers());
51
- if (!isAbsolute(destination)) {
52
- destination = resolve(Path.pwd(), destination);
53
- }
54
- return destination;
55
- }
56
- /**
57
- * Get the import path that should be registered in RC file.
58
- */
59
- getImportPath(fileName) {
60
- const destination = this.getDestinationPath();
61
- return `${destination
62
- .replace(Path.pwd(), '')
63
- .replace(/\\/g, '/')
64
- .replace('/', '#')}/${fileName}`;
65
- }
66
41
  }
67
42
  __decorate([
68
43
  Argument({
@@ -12,16 +12,4 @@ export declare class MakeInterceptorCommand extends BaseCommand {
12
12
  static signature(): string;
13
13
  static description(): string;
14
14
  handle(): Promise<void>;
15
- /**
16
- * Get the file path where it will be generated.
17
- */
18
- private getFilePath;
19
- /**
20
- * Get the destination path for the file that will be generated.
21
- */
22
- private getDestinationPath;
23
- /**
24
- * Get the import path that should be registered in RC file.
25
- */
26
- private getImportPath;
27
15
  }
@@ -16,7 +16,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
16
16
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
17
17
  };
18
18
  import { Path } from '@athenna/common';
19
- import { sep, resolve, isAbsolute } from 'node:path';
20
19
  import { BaseCommand, Argument } from '@athenna/artisan';
21
20
  export class MakeInterceptorCommand extends BaseCommand {
22
21
  static signature() {
@@ -27,42 +26,18 @@ export class MakeInterceptorCommand extends BaseCommand {
27
26
  }
28
27
  async handle() {
29
28
  this.logger.simple('({bold,green} [ MAKING INTERCEPTOR ])\n');
29
+ const destination = Config.get('rc.commands.make:interceptor.destination', Path.interceptors());
30
30
  const file = await this.generator
31
- .path(this.getFilePath())
31
+ .fileName(this.name)
32
+ .destination(destination)
32
33
  .template('interceptor')
33
34
  .setNameProperties(true)
34
35
  .make();
35
36
  this.logger.success(`Interceptor ({yellow} "${file.name}") successfully created.`);
36
- const importPath = this.getImportPath(file.name);
37
+ const importPath = this.generator.getImportPath();
37
38
  await this.rc.pushTo('middlewares', importPath).save();
38
39
  this.logger.success(`Athenna RC updated: ({dim,yellow} [ middlewares += "${importPath}" ])`);
39
40
  }
40
- /**
41
- * Get the file path where it will be generated.
42
- */
43
- getFilePath() {
44
- return this.getDestinationPath().concat(`${sep}${this.name}.${Path.ext()}`);
45
- }
46
- /**
47
- * Get the destination path for the file that will be generated.
48
- */
49
- getDestinationPath() {
50
- let destination = Config.get('rc.commands.make:interceptor.destination', Path.interceptors());
51
- if (!isAbsolute(destination)) {
52
- destination = resolve(Path.pwd(), destination);
53
- }
54
- return destination;
55
- }
56
- /**
57
- * Get the import path that should be registered in RC file.
58
- */
59
- getImportPath(fileName) {
60
- const destination = this.getDestinationPath();
61
- return `${destination
62
- .replace(Path.pwd(), '')
63
- .replace(/\\/g, '/')
64
- .replace('/', '#')}/${fileName}`;
65
- }
66
41
  }
67
42
  __decorate([
68
43
  Argument({
@@ -12,16 +12,4 @@ export declare class MakeMiddlewareCommand extends BaseCommand {
12
12
  static signature(): string;
13
13
  static description(): string;
14
14
  handle(): Promise<void>;
15
- /**
16
- * Get the file path where it will be generated.
17
- */
18
- private getFilePath;
19
- /**
20
- * Get the destination path for the file that will be generated.
21
- */
22
- private getDestinationPath;
23
- /**
24
- * Get the import path that should be registered in RC file.
25
- */
26
- private getImportPath;
27
15
  }
@@ -16,7 +16,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
16
16
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
17
17
  };
18
18
  import { Path } from '@athenna/common';
19
- import { sep, resolve, isAbsolute } from 'node:path';
20
19
  import { BaseCommand, Argument } from '@athenna/artisan';
21
20
  export class MakeMiddlewareCommand extends BaseCommand {
22
21
  static signature() {
@@ -27,42 +26,18 @@ export class MakeMiddlewareCommand extends BaseCommand {
27
26
  }
28
27
  async handle() {
29
28
  this.logger.simple('({bold,green} [ MAKING MIDDLEWARE ])\n');
29
+ const destination = Config.get('rc.commands.make:middleware.destination', Path.middlewares());
30
30
  const file = await this.generator
31
- .path(this.getFilePath())
31
+ .fileName(this.name)
32
+ .destination(destination)
32
33
  .template('middleware')
33
34
  .setNameProperties(true)
34
35
  .make();
35
36
  this.logger.success(`Middleware ({yellow} "${file.name}") successfully created.`);
36
- const importPath = this.getImportPath(file.name);
37
+ const importPath = this.generator.getImportPath();
37
38
  await this.rc.pushTo('middlewares', importPath).save();
38
39
  this.logger.success(`Athenna RC updated: ({dim,yellow} [ middlewares += "${importPath}" ])`);
39
40
  }
40
- /**
41
- * Get the file path where it will be generated.
42
- */
43
- getFilePath() {
44
- return this.getDestinationPath().concat(`${sep}${this.name}.${Path.ext()}`);
45
- }
46
- /**
47
- * Get the destination path for the file that will be generated.
48
- */
49
- getDestinationPath() {
50
- let destination = Config.get('rc.commands.make:middleware.destination', Path.middlewares());
51
- if (!isAbsolute(destination)) {
52
- destination = resolve(Path.pwd(), destination);
53
- }
54
- return destination;
55
- }
56
- /**
57
- * Get the import path that should be registered in RC file.
58
- */
59
- getImportPath(fileName) {
60
- const destination = this.getDestinationPath();
61
- return `${destination
62
- .replace(Path.pwd(), '')
63
- .replace(/\\/g, '/')
64
- .replace('/', '#')}/${fileName}`;
65
- }
66
41
  }
67
42
  __decorate([
68
43
  Argument({
@@ -12,16 +12,4 @@ export declare class MakeTerminatorCommand extends BaseCommand {
12
12
  static signature(): string;
13
13
  static description(): string;
14
14
  handle(): Promise<void>;
15
- /**
16
- * Get the file path where it will be generated.
17
- */
18
- private getFilePath;
19
- /**
20
- * Get the destination path for the file that will be generated.
21
- */
22
- private getDestinationPath;
23
- /**
24
- * Get the import path that should be registered in RC file.
25
- */
26
- private getImportPath;
27
15
  }
@@ -16,7 +16,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
16
16
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
17
17
  };
18
18
  import { Path } from '@athenna/common';
19
- import { sep, resolve, isAbsolute } from 'node:path';
20
19
  import { BaseCommand, Argument } from '@athenna/artisan';
21
20
  export class MakeTerminatorCommand extends BaseCommand {
22
21
  static signature() {
@@ -27,42 +26,18 @@ export class MakeTerminatorCommand extends BaseCommand {
27
26
  }
28
27
  async handle() {
29
28
  this.logger.simple('({bold,green} [ MAKING TERMINATOR ])\n');
29
+ const destination = Config.get('rc.commands.make:terminator.destination', Path.terminators());
30
30
  const file = await this.generator
31
- .path(this.getFilePath())
31
+ .fileName(this.name)
32
+ .destination(destination)
32
33
  .template('terminator')
33
34
  .setNameProperties(true)
34
35
  .make();
35
36
  this.logger.success(`Terminator ({yellow} "${file.name}") successfully created.`);
36
- const importPath = this.getImportPath(file.name);
37
+ const importPath = this.generator.getImportPath();
37
38
  await this.rc.pushTo('middlewares', importPath).save();
38
39
  this.logger.success(`Athenna RC updated: ({dim,yellow} [ middlewares += "${importPath}" ])`);
39
40
  }
40
- /**
41
- * Get the file path where it will be generated.
42
- */
43
- getFilePath() {
44
- return this.getDestinationPath().concat(`${sep}${this.name}.${Path.ext()}`);
45
- }
46
- /**
47
- * Get the destination path for the file that will be generated.
48
- */
49
- getDestinationPath() {
50
- let destination = Config.get('rc.commands.make:terminator.destination', Path.terminators());
51
- if (!isAbsolute(destination)) {
52
- destination = resolve(Path.pwd(), destination);
53
- }
54
- return destination;
55
- }
56
- /**
57
- * Get the import path that should be registered in RC file.
58
- */
59
- getImportPath(fileName) {
60
- const destination = this.getDestinationPath();
61
- return `${destination
62
- .replace(Path.pwd(), '')
63
- .replace(/\\/g, '/')
64
- .replace('/', '#')}/${fileName}`;
65
- }
66
41
  }
67
42
  __decorate([
68
43
  Argument({