@athenna/http 1.4.4 → 1.4.5

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": "1.4.4",
3
+ "version": "1.4.5",
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>",
@@ -30,7 +30,9 @@
30
30
  "src/*.js",
31
31
  "src/*.d.ts",
32
32
  "src/**/*.js",
33
- "src/**/*.d.ts"
33
+ "src/**/*.d.ts",
34
+ "templates/*",
35
+ "templates/**/*"
34
36
  ],
35
37
  "type": "module",
36
38
  "main": "./src/index.js",
@@ -0,0 +1,52 @@
1
+ export class <%= namePascal %>Controller {
2
+ /**
3
+ * Resolve any dependency of the service container
4
+ * inside the constructor.
5
+ */
6
+ constructor() {}
7
+
8
+ /**
9
+ * Index method
10
+ *
11
+ * @param {import('@athenna/http').ContextContract} ctx
12
+ */
13
+ async index({ response }) {
14
+ return response.status(200).send([{}])
15
+ }
16
+
17
+ /**
18
+ * Store method
19
+ *
20
+ * @param {import('@athenna/http').ContextContract} ctx
21
+ */
22
+ async store({ response }) {
23
+ return response.status(201).send({})
24
+ }
25
+
26
+ /**
27
+ * Show method
28
+ *
29
+ * @param {import('@athenna/http').ContextContract} ctx
30
+ */
31
+ async show({ response }) {
32
+ return response.status(200).send({})
33
+ }
34
+
35
+ /**
36
+ * Update method
37
+ *
38
+ * @param {import('@athenna/http').ContextContract} ctx
39
+ */
40
+ async update({ response, params }) {
41
+ return response.status(200).send({ id: params.id })
42
+ }
43
+
44
+ /**
45
+ * Delete method
46
+ *
47
+ * @param {import('@athenna/http').ContextContract} ctx
48
+ */
49
+ async delete({ response }) {
50
+ return response.status(204)
51
+ }
52
+ }
@@ -0,0 +1,40 @@
1
+ export class <%= namePascal %>Middleware {
2
+ /**
3
+ * Resolve any dependency of the service container
4
+ * inside the constructor.
5
+ */
6
+ constructor() {}
7
+
8
+ /**
9
+ * Handle method is executed before the request gets
10
+ * in your controller.
11
+ *
12
+ * @param {import('@athenna/http').HandleContextContract} ctx
13
+ */
14
+ async handle({ next }) {
15
+ next()
16
+ }
17
+
18
+ /**
19
+ * Intercept method is executed before the response
20
+ * has been sent.
21
+ *
22
+ * @param {import('@athenna/http').InterceptContextContract} ctx
23
+ */
24
+ async intercept({ body }) {
25
+ body.intercepted = true
26
+
27
+ return body
28
+ }
29
+
30
+ /**
31
+ * Terminate method is executed after the response
32
+ * has been sent.
33
+ *
34
+ * @param {import('@athenna/http').TerminateContextContract} ctx
35
+ * @return any
36
+ */
37
+ async terminate({ next }) {
38
+ next()
39
+ }
40
+ }