@athenna/http 1.5.7 → 1.6.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 +2 -2
- package/src/Commands/Make/Controller.js +6 -15
- package/src/Commands/Make/Middleware.js +9 -17
- package/src/Commands/Route/List.js +2 -2
- package/src/Helpers/HttpCommandsLoader.js +4 -3
- package/templates/{__name__Controller.js.ejs → controller.ejs} +1 -1
- package/templates/{__name__Middleware.js.ejs → middleware.ejs} +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@athenna/http",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.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>",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"#tests/*": "./tests/*.js"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@athenna/artisan": "1.3
|
|
57
|
+
"@athenna/artisan": "1.4.3",
|
|
58
58
|
"@athenna/ioc": "1.2.3",
|
|
59
59
|
"@athenna/logger": "1.2.8",
|
|
60
60
|
"@secjs/utils": "1.9.7",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @athenna/
|
|
2
|
+
* @athenna/http
|
|
3
3
|
*
|
|
4
4
|
* (c) João Lenon <lenon@athenna.io>
|
|
5
5
|
*
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import { Path
|
|
11
|
-
import {
|
|
10
|
+
import { Path } from '@secjs/utils'
|
|
11
|
+
import { Command } from '@athenna/artisan'
|
|
12
12
|
|
|
13
13
|
export class MakeController extends Command {
|
|
14
14
|
/**
|
|
@@ -53,21 +53,12 @@ export class MakeController extends Command {
|
|
|
53
53
|
*/
|
|
54
54
|
async handle(name, options) {
|
|
55
55
|
const resource = 'Controller'
|
|
56
|
-
const
|
|
56
|
+
const path = Path.http(`Controllers/${name}.js`)
|
|
57
57
|
|
|
58
|
-
this.
|
|
59
|
-
`[ MAKING ${resource.toUpperCase()} ]\n`,
|
|
60
|
-
'rmNewLineStart',
|
|
61
|
-
'bold',
|
|
62
|
-
'green',
|
|
63
|
-
)
|
|
58
|
+
this.title(`MAKING ${resource}\n`, 'bold', 'green')
|
|
64
59
|
|
|
65
|
-
const file = await
|
|
60
|
+
const file = await this.makeFile(path, 'controller', options.lint)
|
|
66
61
|
|
|
67
62
|
this.success(`${resource} ({yellow} "${file.name}") successfully created.`)
|
|
68
|
-
|
|
69
|
-
if (options.lint) {
|
|
70
|
-
await Artisan.call(`eslint:fix ${file.path} --resource ${resource}`)
|
|
71
|
-
}
|
|
72
63
|
}
|
|
73
64
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @athenna/
|
|
2
|
+
* @athenna/http
|
|
3
3
|
*
|
|
4
4
|
* (c) João Lenon <lenon@athenna.io>
|
|
5
5
|
*
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { Path, String } from '@secjs/utils'
|
|
11
|
-
import {
|
|
11
|
+
import { Command, FilePropertiesHelper } from '@athenna/artisan'
|
|
12
12
|
|
|
13
13
|
export class MakeMiddleware extends Command {
|
|
14
14
|
/**
|
|
@@ -55,29 +55,21 @@ export class MakeMiddleware extends Command {
|
|
|
55
55
|
*/
|
|
56
56
|
async handle(name, options) {
|
|
57
57
|
const resource = 'Middleware'
|
|
58
|
-
const
|
|
58
|
+
const path = Path.http(`Middlewares/${name}.js`)
|
|
59
59
|
|
|
60
|
-
this.
|
|
61
|
-
`[ MAKING ${resource.toUpperCase()} ]\n`,
|
|
62
|
-
'rmNewLineStart',
|
|
63
|
-
'bold',
|
|
64
|
-
'green',
|
|
65
|
-
)
|
|
60
|
+
this.title(`MAKING ${resource}\n`, 'bold', 'green')
|
|
66
61
|
|
|
67
|
-
const file = await
|
|
62
|
+
const file = await this.makeFile(path, 'middleware', options.lint)
|
|
68
63
|
|
|
69
64
|
this.success(`${resource} ({yellow} "${file.name}") successfully created.`)
|
|
70
65
|
|
|
71
|
-
if (options.lint) {
|
|
72
|
-
await Artisan.call(`eslint:fix ${file.path} --resource ${resource}`)
|
|
73
|
-
}
|
|
74
|
-
|
|
75
66
|
if (options.register) {
|
|
76
|
-
await
|
|
67
|
+
await FilePropertiesHelper.addContentToObjectGetter(
|
|
77
68
|
Path.http('Kernel.js'),
|
|
78
69
|
'namedMiddlewares',
|
|
79
|
-
|
|
80
|
-
|
|
70
|
+
`${String.toCamelCase(
|
|
71
|
+
file.name,
|
|
72
|
+
)}: import('#app/Http/Middlewares/${name}')`,
|
|
81
73
|
)
|
|
82
74
|
}
|
|
83
75
|
}
|
|
@@ -53,7 +53,7 @@ export class RouteList extends Command {
|
|
|
53
53
|
* @return {Promise<void>}
|
|
54
54
|
*/
|
|
55
55
|
async handle(options) {
|
|
56
|
-
this.
|
|
56
|
+
this.title('ROUTE LISTING\n', 'bold', 'green')
|
|
57
57
|
|
|
58
58
|
const Kernel = await Module.getFrom(Path.http('Kernel.js'))
|
|
59
59
|
|
|
@@ -102,6 +102,6 @@ export class RouteList extends Command {
|
|
|
102
102
|
rows.push(row)
|
|
103
103
|
})
|
|
104
104
|
|
|
105
|
-
this.
|
|
105
|
+
this.log(this.createTable({ head: header }, ...rows))
|
|
106
106
|
}
|
|
107
107
|
}
|
|
@@ -21,8 +21,9 @@ export class HttpCommandsLoader {
|
|
|
21
21
|
* @return {any[]}
|
|
22
22
|
*/
|
|
23
23
|
static loadTemplates() {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
const dirname = Module.createDirname(import.meta.url)
|
|
25
|
+
const templatesPath = join(dirname, '..', '..', 'templates')
|
|
26
|
+
|
|
27
|
+
return new Folder(templatesPath).loadSync().getFilesByPattern('**/*.ejs')
|
|
27
28
|
}
|
|
28
29
|
}
|